Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you know request URL?

Status
Not open for further replies.

BPetro

Programmer
Oct 1, 2002
59
US
I know that every myPage.jsp has an implicit variable for request and response and config and other items but within all of those I cannot find any api to get at the URL of the current page.
1. How can programatically get the current URL?
2. Can I include a file that checks that for every page?

To give you the big picture - here's that I want to do. Include (via include hopefully) an opening set of code in every page, that does the following pseudo code steps...
1. MySession.setCurrentURL(this page's URL)
2. If MySession.isLoggedIn() = false then go to login page.
3. Then in Login page after they login, return to the page that jumped to login.

Make sense? Any answers to my specific questions - OR any "why don't you do it this easier way?" type suggestions are welcomed!

THANKS!!
 
PS: I maybe should have mentioned that MySession is a simple bean included in every page that can carry some basic information about the application and session and user in general.
 
OK, I believe I have found it so I'll leave the answer for anyone else needing this info...

HOWEVER - if anyone has any better ideas on how to do the force login as page1 -> login page -> back to -> page1 feel free to give some better ideas.

To output the current URL ...
<%=request.getRequestURL()%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top