This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
i am designing a website for a shopping mall. here i have some items on a page. when i click on 1 item, its detailed information must be shown to the user. i created a servlet for that. when the user click on the item , onitemclick is called which get the data from database and the forward it to a jsp items.jsp.. so now i think when the servlet forward, the url must be http://localhost:8080/project2/pages/items.jsp but i am not getting this url in browser. i got the url http://localhost:8080/project2/itemclick?x=63&y=96&text1=l1 .... please tell me why i am getting this url.
Joined: Jan 24, 2012
the problem due to this url change is that i am not getting the image on jsp.. when instead of this url i enter manually the url http://localhost:8080/project2/pages/items.jsp the image is displayed. please help me. its very urgent.
1. You have a HTML form inside a jsp page whose action is http://localhost:8080/project2/addcart.
2. The URL pattern "/addcart" is mapped to a Servlet
3. The Servlet does it processing in its doGet method as you invoke it via HTTP get method in the HTML form.
4. It executes a SQL query
5. It checks for the result set with an if-else for any valid rows being returned
6. If there are any valid rows [while(rs.next()..] it forwards the control to /pages/items.jsp via RequestDispatcher. 7. If there are NO valid rows (else), it prints out an error message.
Now, you have to confirm whether you get the #7 above is executed or not. Are there any valid rows being returned? Execute your SQL query directly in the SQL Client and try to see.
Bear Bibeault wrote:The URL for the JSP will never be shown as the result of a forward, and it shouldn't! If it did, a refresh on the browser would cause the JSP to try and display again without running its controller.