i know in PHP, there's a static constant called PHP_SELF which stores the current URL. is there an equivalent of this for JSP?
thank you
Discussions
Web tier: servlets, JSP, Web frameworks: how can i determine the current URL in a jsp page?
-
how can i determine the current URL in a jsp page? (2 messages)
- Posted by: Shawn Wall
- Posted on: April 10 2001 13:59 EDT
Threaded Messages (2)
- how can i determine the current URL in a jsp page? by Pradeep Nair on April 10 2001 20:24 EDT
- how can i determine the current URL in a jsp page? by J Dev on March 25 2011 07:58 EDT
-
how can i determine the current URL in a jsp page?[ Go to top ]
- Posted by: Pradeep Nair
- Posted on: April 10 2001 20:24 EDT
- in response to Shawn Wall
Hi! Shawn:
JSP on compilation generates a servlet thus the request, response objects are readily available.
The following scriptlet (Java code) should give you what you need
<%= request.getRequestURI() %>
This will print the URI to the browser. If you want to store it in a variable use the following
<% String myURI = request.getRequestURI(); %>
If you need the value as a URL you will need to use the following
<%@ page import="javax.servlet.http.HttpUtils.*" %>
<%= javax.servlet.http.HttpUtils.getRequestURL(request) %>
in the JSP.
Pradeep.
-
how can i determine the current URL in a jsp page?[ Go to top ]
- Posted by: J Dev
- Posted on: March 25 2011 07:58 EDT
- in response to Shawn Wall
you can getRequestURI() and getRequestURL() functions. See Servlet request for more details about the request methods