tags:

views:

37

answers:

1

Hi,

May be this is the basic Question. But i am not able to understand how to get it. My browser url is http://testweb/edit.htm'. testweb is context path. This uri is from Spring. I need to get edit.htm which is after context, in my jsp. How to get this. Thank you for the support

Thanks, Santha/

+1  A: 

The HttpServletRequest offers several methods to access (parts of) the request URL, under each the HttpServletRequest#getRequestURI() and #getServletPath().

That said, this job should be done in a Filter or maybe a Servlet rather than a JSP file.


Update: you seem to be using Spring and rather be interested in the request URI which called the forwarded JSP. You can get it as request attribute with the key RequestDispatcher#FORWARD_REQUEST_URI as follows:

String uri = request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);

or in JSP EL as follows:

${requestScope['javax.servlet.forward.request_uri']}
BalusC
I tried them. Those all methods are retrieving the jsp.Means. If i execute url edit.htm, spring forward to editXXX.jsp. So by executing those methods i am getting editXXX.jsp but not edit.htm
vishnu
I see what you mean. I updated the answer.
BalusC
Thank you. I think this is part of Java 6. But i am using below version which is 5. So can i have any other solution in this version.
vishnu
JSP EL ${requestScope['javax.servlet.forward.request_uri']} is working. Thanks a lot
vishnu
No, it's not specific to Java 6. It has been in Servlet API all the time. Don't forget to mark the answer accepted if it helped in solving the problem. See also http://stackoverflow.com/faq
BalusC