[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

jsp from page

Hi Experts,

How can I get URL of some page where my main JSP page was opened from ?

Thank you.
0
fpoyavo
Asked:
fpoyavo
  • 6
  • 5
1 Solution
 
objectsCommented:
<%
String uri = request.getRequestURI();
String querystring = request.getQueryString();
%>
0
 
objectsCommented:
also:

StringBuffer url = request.getRequestURL();
0
 
fpoyavoAuthor Commented:
I was trying it before I posted this question. For some reason I get main jsp url not the one where it was initiated from.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
objectsCommented:
Sorry misunderstood what u wanted.
If you want the URL of the page that called the jsp, check the referer request header.

request.getHeader("referer");
0
 
fpoyavoAuthor Commented:
You mean Just in main.jsp :

String ref = request.getHeader("referer");

0
 
fpoyavoAuthor Commented:
Can it be a problem if I open main.jsp using javascript from html ?
0
 
objectsCommented:
the referer header is not guarnteed to be there, i think it is dependant on the browser as to whether it is included or not.

You could pass the url as a query parameter when you call main.jsp.
0
 
fpoyavoAuthor Commented:
I am trying to accomplish the following thing:

1 It is login page
2 I cannot use cookies or session becuase of client's requirements
3 I get user, password if valid then open main.jsp using javascript
4 in main.jsp I would check if page where it was opened from login.html
5 if it is then continue if not go to login.jsp  

The problem is that I want to check it only first time. I would keep it in  my url but don't want to check it every time page processed
and besides that the url is changing constantly due to application requests.

Is it doable without session variables and cookies ?

Thank you.
0
 
objectsCommented:
> Is it doable without session variables and cookies ?

Not that I can think of.

Are you using a database? If so you could store some unique key for the user when they logged in and pass that id as a parameter to every page and use that to lookup database to determine if user logged in ok. bit messy though.
0
 
objectsCommented:
How come the client doesn't want to use sessions?
0
 
fpoyavoAuthor Commented:
:) Sometimes they do.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now