Home Jsp Jsp Absolute Path
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Jsp Absolute Path

Advertisement
This section demonstrates you to get the absolute path in jsp.

Jsp Absolute Path

        

This section demonstrates you to get the absolute path in jsp. The absolute path is the full path that contains the root directory instead of a few directories contained within the absolute path. The absolute path always begin with a / (slash). You can see in the given example, in order to get the absolute path of jsp file, we have used the method getServletContext().getRealPath("/").

Understand with Example

The Tutorial illustrate an example from 'JSP Absolute Path'. To understand JSP Absolute Path example we create a a html tag that embeded the java expression. The HTML can be turned into jsp by changing the extension of .html into absolute .jsp. The following text code is put in a file called AbsoluePath.jsp. Place the Absolute.jsp  into your JSP directory and able to view in browser.

<%= getServletContext().getRealPath("/")> : The <%=> is used to embed Java expression in JSP pages The    getServletContext().getRealPath("/") method is used to get the absolute path of jsp file. The absolute path is the full path that gives you the information about the root directory in which jsp file is placed.

Here is the code of AbsolutePath.jsp

<html>
<head><title>Absolute Path</title></head>
Absolute Path is:<%= getServletContext().getRealPath("/") %> 
</html>

Following output will be displayed on the browser:

Download Source Code:

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 15, 2009

Related Tutorials

Ask Questions?    Discuss: Jsp Absolute Path   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com