aspose file tools
The moose likes Servlets and the fly likes request.getPathInfo() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "request.getPathInfo()" Watch "request.getPathInfo()" New topic
Author

request.getPathInfo()

Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
Hi can someone tell me what file path is getPathInfo() referring to?
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class FileLocation extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
if (req.getPathInfo() != null) {
out.println("The file \"" + req.getPathInfo() + "\"");
out.println("Is stored at \"" + req.getPathTranslated() + "\"");
}
}
}
What is the output of the above code?
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
According to the Servlet api getPathInfo(),
"Returns:
a String specifying extra path information that comes after the servlet path but before the query string in the request URL; or null if the URL does not have any extra path information"
Which I take to mean the xxx in a path like this
http://www.site.com/servlet/MyServlet/xxx?name=value

Sean
 
I agree. Here's the link: jrebel
 
subject: request.getPathInfo()
 
Similar Threads
How to read data from a text file
which API could get Method name and calling line number ?
How to pick up the servlet in the URL
JSP EDITOR QUETION? NEED HELP
whilst fooling around with SessionId and cookies...