I have a login servlet and based on the user type it needs to forward user to specific types of profile/main pages. It does whats it suppose to do but the url on the browser shows the servlet name. "http://localhost:8080/project/LoginServlet" instead of showing "http://localhost:8080/project/Admin/mainPage.jsp"
How do I achieve this???
Himanshu Kansal wrote:You'll ned to give a mapping for the servlet to a particular jsp. Do it in web.xml if you are not using any framework like Struts.
Thanks for the reply
But how do I map a servlet that can map to several JSP like this case. Can you please give an example of multiple mapping from one servlet. Or an example to do the mapping for the servlet to a particular jsp
thanks in advance
Bear Bibeault wrote:You don't. That's the whole point of the forward!
Why would you want it to?
Well I was just curious if there was a way to show the right jsp rather than the servlet in the url. It would help me fix some problem with the urls that i am facing in later part of the project. for example after deleting a user It sends the admin back to main page and from that page if I click any link that gets messed up as the context url is showing the deletservlet link.
Bear Bibeault wrote:You're not following the proper patterns -- that's what's causing your problems. The solution isn't to try and trick the forward (you can't) but to structure your application correctly.
Read this article and pay particular attention to the "PRG Pattern".
thanks a lot....for the article
I guess now I get to spend my weekend in a productive way