This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Servlets and the fly likes Redirecting to the same jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Redirecting to the same jsp page" Watch "Redirecting to the same jsp page" New topic

Redirecting to the same jsp page

Ramkumar Subburaj
Ranch Hand

Joined: Sep 07, 2007
Posts: 83

I have 10 pages in my application and each page has a log in section.

So when the user tries to log in from any any of these 10 pages, i want to redirect the user to the same page.

is there a way in servlet to find from which jsp page the request comes or what is the best way to do it?

SCJP 1.5, SCWCD 1.4.
Hanging between Web Services and EJB
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63540

You're doing it the hard way. Why have a login on each page?

Rather, check for authentication in a servlet filter. If the user is not logged in, record the URL in the session and forward to a single login page. After login, redirect to the stored URL.

[Asking smart questions] [About Bear] [Books by Bear]
wood burning stoves
subject: Redirecting to the same jsp page
jQuery in Action, 3rd edition