Absolute path vs Relative path


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Absolute path vs Relative path

  1. #1
    Join Date
    Sep 2005
    Posts
    3

    Absolute path vs Relative path

    Hi friends,
    I am pretty much new in java. I want to know what is the difference between Absolute path and relative path? I have one more doubt, in the following code i have a link, if the user clicks on the i want to take him to test.html which is stored in my home directory, that is /home/max/test.html. if i store that page inside the web-app directory it will work, but i just want to know if i keep that file somewhere else other than web-app directory then how to forward an user to that page.
    Code:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    
    public class CustomTagTest extends HttpServlet {
    
    	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	
    		response.setContentType("text/html");
    		PrintWriter out = response.getWriter();
    		
    		out.println("<html>");
    		out.println("<head>");
    		out.println("<title>Testing custom tags with servlet</title>");
    		out.println("</head>");
    		out.println("<body bgcolor=pink>");
    		out.println("<br><br><br><center>");
    		out.println("<form method=post>");
    		out.println("<table>");
    		out.println("<tr>");
    		out.println("<td>Name</td>");
    		out.println("<td><input type=text name=userName></td>");
    		out.println("</tr>");
    		out.println("<tr>");
    		out.println("<td>NINO</td>");
    		out.println("<td><input type=text name=userNino></td>");
    		out.println("</tr>");
    		out.println("<tr>");
    		out.println("<br><br><td><input type=submit value=Submit></td>");
    		out.println("<br><br><td><a href=/home/max/test.html>Go to the Shopping Cart</a></td>");
    		out.println("</tr>");
    		out.println("</table>");
    		out.println("</form>");
    		out.println("</center>");
    		out.println("</body>");
    		out.println("</html>");
    	}
    	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    
    		RequestDispatcher rd = request.getRequestDispatcher("/CustomTagTest.jsp");
    		rd.forward(request,response);
    	}
    Thanks in advance

  2. #2
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    10
    lets say you have a file on the desktop and you want it to access something in a folder called New Folder

    absolute path is a full reference
    like "C:\Docuements and Settings\User Name\Desktop\New Folder"
    whereas a reletive path is a path RELETIVE to the file that is executing the path
    like "New Folder"
    I prefer to live in my own shadow. At least then I can be compared to a false past I'm more familiar with

  3. #3
    Join Date
    Sep 2005
    Posts
    3

    Absolute path vs Relative path

    Hi Chirone,
    Thanks for the reply. I've posted one more doubt with the previous, that is how we are going to forward an user to a page which is not stored under the web-app dir, say its stored under /home/userName/page.html in linux OS. If you can tell me something about this one, it will greatly help me.

    Thanks again.

  4. #4
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    10
    ummm, that's out of my knowledge range I think...
    I prefer to live in my own shadow. At least then I can be compared to a false past I'm more familiar with

  5. #5
    Join Date
    Sep 2005
    Posts
    3

    Absolute path vs Relative path

    Well thanks for your attention. But i think the problem is quite interesting. I hope somebody has the solution.

Similar Threads

  1. Relative path for loading file
    By tomz2000 in forum VB Classic
    Replies: 8
    Last Post: 09-27-2007, 07:38 PM
  2. Breadth first search with java
    By Ant_Magma in forum Java
    Replies: 26
    Last Post: 03-07-2006, 08:12 AM
  3. Retreive Absolute Path
    By Litha in forum Java
    Replies: 3
    Last Post: 02-28-2005, 10:03 AM
  4. Replies: 9
    Last Post: 06-20-2001, 06:32 PM
  5. Virtual Path
    By Nate in forum Enterprise
    Replies: 0
    Last Post: 02-08-2001, 09:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center