August 12th, 2002, 06:51 AM
URL updating from a servlet dispatcher
I got a jsp page (MeetingQuery.jsp) with a form whose action is:
This servlet processes the request and then sends user back to MeetingQuery.jsp:
rd = request.getRequestDispatcher("/MeetingQuery.jsp");
The problem is that in the URL we can see:
Instead, I would like to see .../Meeting/MeetingQuery.jsp again. Is it possible and if yes, how to do that?
Thanks for your answers!
August 13th, 2002, 04:09 PM
You might give the user a "query successful" mesage (like this board does when you post a reply), then redirect them to the jsp.
August 16th, 2002, 07:20 PM
September 15th, 2002, 06:08 PM
The solution to this problem is not hard, but it required some research.
I didn't get any help from anyone and I couldn't find a tutorial, but I got some idea to put the path after the servlet and use a servlet mapping in web.xml.
My idea was that I could then parse the location from the servlet to get the real page I wanted to go to. This would allow me to have doGet and doPost handle the page almost identically while using a RequestDispatcher.
It turns out that the servlet API already has such feature, so I was partially reinventing the wheel. The method is getPathInfo of HttpServletRequest.
I made a quick tutorial on it and put it on my website.
You'll be surprised how easy it is.
September 15th, 2002, 11:15 PM
You can also use response.sendRedirect() in place of request.getRequestDispatcher().forward(). The disadvantage of this of course is that you can't send the request and response objects on, but you can still use sessions and the query string.