You've 2 synchronous lists whose items are related to each other. This is not really easy to maintain and traverse. Rather put the values of the two lists in a Map.
You've 2 synchronous lists whose items are related to each other. This is not really easy to maintain and traverse. Rather put the values of the two lists in a Map.
Map courses = new LinkedHashMap(); // ... while(resultSet.next()) { map. Put(resultSet. GetString(1), resultSet.
GetString(2)); } // ... request. SetAttribute("courses", courses); In JSP you can use the JSTL tag to iterate over a List or a Map. In case of a Map, each iteration will give you a Map.
Entry in the var attribute which in turn has getKey() and getValue() methods. So this should do: ... ${course. Value} Further, the first two lines in your processRequest() method response.
SetContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); should be removed since that's the responsibly of the JSP, not the servlet. You will otherwise risk IllegalStateException errors when doing so. Also get rid of the @page import in top of your JSP.
They are at the wrong place, all associated code belongs in the servlet.
Thanks. I've change my code with the above code. But it is not working.
Can you tell where i've to call the servlet in the jsp? – Kanika Deka May 5 at 14:21 Call the servlet by its URL as you've definied in web.xml. If it is for example /removeCourse then you need to call it by http://localhost:8080/ONLINE_EXAM/removeCourse.
You should however also change the RequestDispatcher path to /removeCourse.jsp. See also our wiki page to learn how to use servlets stackoverflow. Com/tags/servlets/info – BalusC May 5 at 14:22 I use RequestDispatcher to forward the response to jsp.
But still it is not working.In my jsp what code should i've to write to get the response from the servlet – Kanika Deka May 5 at 14:58 Nothing. You just use request. SetAttribute("courses", courses); in servlet and it'll be available as ${courses} in JSP.
If you still see a blank page when you invoke the servlet URL, then read the server logs. You only need to ensure that your web. Xml matches the highest servlet version as supported by the container you're running.
– BalusC May 5 at 15:05 I am using Netbeans 6.0.1 and my web. Xml version is 2.5. Is any problem with this version? – Kanika Deka May 5 at 16:30.
Class MyBean{ String val; String label; //+getters setters method } Servlet //fetching list of MyBean and setting it to request as attribute request. SetAttribute("beanList",beanList); // forward this request to jsp jsp ${bean. Label}.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.