• Post Reply Bookmark Topic Watch Topic
  • New Topic

Path of jsp files.  RSS feed

 
arada theera
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know physical path of jsp file when it locate on web server.
How can I print out path on jsp page ?
 
jyothsna kumari
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If i understood your question correctly,i think by doing something like this you can get the entire path of the JSP page. From this you can get the physical path.

<script language=javascript>
var myURL = window.location.href+"";
alert(myURL);
</script>

Thanks,
Jyothsna
 
Adeeb Abdul Karim
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can use the following methods in the request object available in JSP

String getPathInfo()
String getPathTranslated()
String getQueryString()
String getRequestURI()
StringBuffer getRequestURL()
String getServletPath()

Refer the API documentation for details
 
arada theera
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for answers.
I'll try your answer.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you're looking for is 'getRealPath'.


It is not a good practice to rely on this though.
If your app is being run directly from a war file, as opposed to an exploded file system, this method will return null.

It's bad form in J2EE for an app to rely on the physical location of it's files.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!