Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request.getPathInfo()

 
Bob Moranski
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic