| Author |
Printing the requesturl?
|
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Hi Guys, I'm trying to print the request url in a jsp and I want to do that using EL instead of scriptlet. How can I do this?? Any thoughts on this!
|
SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
${pageContext.request... } will get you access to the requset object. From there you can add any property you like. IE: to see the context path: ${pageContext.request.contextPath} To see the other properties belonging to the request object, see: http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Ben, I tried this and it seems not to work! Here is the jsp file, <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Welcome all!</title> </head> <body> You have accessed this page using a .abc extension, so you are viewing this page <% String url = request.getRequestURI(); System.out.println(url); %> ${pageContext.request.contextPath} </body> </html> The one inside scriptlet seems to work but ${pageContext.request.contextPath} is not printing anything to the tomcat console???
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56177
|
|
Originally posted by Jothi Shankar Kumar Sankararaj: ...but ${pageContext.request.contextPath} is not printing anything to the tomcat console???
Why would you expect any output on the console? This will emit the value to the response.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: Printing the requesturl?
|
|
|