I tried to create a dropdown list using struts2.it is not working.can you find the errors in this code?

I tried to create a dropdown list using struts2.it is not working.can you find the errors in this code?

/jsp code for creating dropdownlist using struts2/

<html>
<body>
<p:form action="addemp" method="post">/*form created*/
<p:select name="designation" label="Enter Designation " list="design" /> /*dropdown list included*/
<p:submit name="submit"/>//submit
</p:form>
</body>
</html>

/java action class for adding form elements and accessing values/

import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.util.*;
import com.opensymphony.xwork2.ActionSupport;
import java.sql.SQLException;
import java.util.ArrayList;

public class EmpAdd extends ActionSupport {

public List<String> design;//list to be dropped
String designation;//the selected string to be taken

public List<String> getDesign() {//getter method of list
    return design;
}

public void setDesign(List<String> design) {/*setter method of list*/
    this.design = design;
}

public String getDesignation() {
    return designation;
}

public void setDesignation(String designation) {
    this.designation = designation;
}

public String execute() throws Exception{


            design = new ArrayList<String>();  //creating the list      
            design.add("es");//adding to the list
            design.add("as");
            return SUCCESS;
}
}

//struts.xml file for controlling

<struts>
<package name="b" extends="struts-default">
<action name="addemp" class="b.EmpAdd" >
<result name="success">addemp.jsp</result>
</action>
</package>
</struts>
View Answers









Related Tutorials/Questions & Answers:
I tried to create a dropdown list using struts2.it is not working.can you find the errors in this code?
Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP
Advertisements
3 dropdown list from the database using JSP
creating list in dropdown using struts - Struts
how to load value in dropdown list after selecting value from first dropdown list using javascript
Can I become a coder at 40?
find a substring by using I/O package
how to perform the client side validations to the dropdown list using javascript?
How to access Contacts from gmail using LDAP in JSP dropdown list
DropDown list
how can i send a mail to a particular user from a many user dropdown list in jsp
dropdown list in jsp
HTML color codes
Dropdown Checkbox list
dropdown list in jsf
ModuleNotFoundError: No module named 'codel'
struts dropdown list
Have you tried PHP resource site; PHPKode.com?
using list iterator create student details - JavaMail
How to create a dependent drop down list using [Apache POI]
How to create a dependent drop down list using [Apache POI]
ModuleNotFoundError: No module named 'codep'
ModuleNotFoundError: No module named 'codep'
ModuleNotFoundError: No module named 'codep'
Can you correct this codes?
JSP Get Data Into Dropdown list From Database
Version of com.intersult>coder dependency
ModuleNotFoundError: No module named 'codev'
dropdown list and text fields in php
Retrieval of Dropdown list
ModuleNotFoundError: No module named 'codex'
ModuleNotFoundError: No module named 'codex'
Calling hibernate query list() method generates errors
Display Errors using Message Resources - Struts
How to create d db for upload files using bolb i m followin dat upload file in db tutorial
getting values from dropdown list
I would like to hire a Coder for iPhone application development
how to set value of dropdown list
how to set value of dropdown list
How to create a Student data base using Linked List in java
jsp- database dependent dropdown list
i am Getting Some errors in Struts - Struts
ModuleNotFoundError: No module named 'codeq-nlp-api'
Maven dependency for com.intersult - coder version 1.5 is released. Learn to use coder version 1.5 in Maven based Java projects
ModuleNotFoundError: No module named 'codev-dashboard'
ModuleNotFoundError: No module named 'codev-dashboard'
getting dropdown values using apache commons in servlet
ModuleNotFoundError: No module named 'codex-africanus'
ModuleNotFoundError: No module named 'codex-africanus'
How do I use JGraph to create a MST(minimum spanning tree) using java?

Ads