Image

Imageswmichele wrote in Imagejava_dev

Jakarta Tomcat + servlets - tiny problem with dispatcher and address line



I'm having a little web-application, using Jakarta Tomcat server, where
JSP is for presentation mainly and servlets are used for business logic
stuff. I have a servlet, which is mapped in web.xml file like this:




<servlet-mapping>

    <servlet-name>Admin</servlet-name>

    <url-pattern>/admin.jsp</url-pattern>

 </servlet-mapping>



After being called by it's url this servlet does some action and
then passes control further, to another .jsp page, using dispatcher:
rd = getServletContext().getRequestDispatcher("/test_page.jsp");
rd.forward(req, res);

And it all works ok and test_page.jsp is being loaded, but what I'm not
happy about is that the address line in a browser still has "admin.jsp" written there, not "test_page.jsp". So if I try to Refresh the page - it would start the servlet Admin again.





Could anyone tell me how to avoid this address thing? I don't want to use encodeURL() though (which doesn't have such problem), because the dispatcher works faster.