Thanks,
Shailesh
Shailesh Narkhede wrote:Nitin,
Actually not getting problem,
but one thing I noticed that, on jsp line number 03 gettting as
Vector dept_Vect = (Vector)request.getAttribute("dept_Vect");
but while setting in listAllDepartments method you are setting at line number 29
request.setAttribute("dept_Vect", listOfDepts);
Dawn Charangat wrote:Nitin, lets take this one staep at a time, okay...
Fine, the first thing :
Change the signature of your method: listAllDepartments(String sql, Object dept_Vect, HttpServletRequest request)
change it to :
public static Vector listAllDepartments() throws DaoException, ClassNotFoundException {
// put the existing code here itself
return dept_Vect;
}
Why because, you are not using any of the parameters passed to this method, for the logic in the method. Okay... did you
understand that ?
Moreover, you shouldnt ideally use the Http objects within other classes other than servlets [generally a bad practice, thats all]. Instead of returning a string from this method, return the vector itself [dont set it in the session in the method]
Once you have done that, change the way the doPost method in the servlet is coded.
// add this:
Vector listOfdepartments = UserDetails.listAllDepartments();
request.setAttribute("dept_Vect", listOfdepartments);
Now try it out, and let me know what you see.
Mohamed Inayath wrote:Change accordingly :
You need not have to pass the paramters.
As you are not using any of those effectively.
Is this called before the JSP is called or how is that..
Mohamed Inayath wrote:All this fine.
What is the first screen you are using?
See currently what is happening is the servlet which is getting the dropdown data is called after the JSP is displayed.
I believe JSP is displayed first and user has to key in the required details and then submit to Register Servlet.
But Drop down list is retrieved during register servlet.
And more over you dont have a Controler Servlet where can pocess the required data for the view.
Mohamed Inayath wrote:1. Have a Controller Servlet. - read some materials on this.
2. Controller Servlet has to retreive all the data required for the view to be displayed.
In your case for ex : Data for the dropdown.
3. After retrieving the necessary data for the view dispatch the request to the view.
4. View then will be displayed
5. Then it has to be submitted to the Register Servlet.
Dawn Charangat wrote:and please stop quoting everything the others type... the volunteers are not visually challenged.
Your code will work only if the servlet gets invoked before the JSP. Because, it is from the servlet the data is being populated.
After the listAllDepartments() method call, when the control reaches the servlet, can you verify if the vector object returned has the
department information you need in the drop down list ?
Consider Paul's rocket mass heater. |