• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to show the jsp Url while forwarding from a servlet

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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???




thanks

Rajib



 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Regards
 
Rajibul Alam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

Regards




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

Rajib
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't. That's the whole point of the forward!

Why would you want it to?
 
Rajibul Alam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you're probably forwarding instead of redirecting.

But as Bear said--you don't *want* to show the JSP in the URL, you want to show the URL of the servlet.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
Rajibul Alam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Get off me! Here, read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic