File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes contextpath,servlet path and full path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "contextpath,servlet path and full path" Watch "contextpath,servlet path and full path" New topic

contextpath,servlet path and full path

Ankur Jain Kothari
Ranch Hand

Joined: Feb 08, 2010
Posts: 154
can anyone give me a link for understanding these..please

Do What You Wanna Be....Taking Things The Way They Come
scjp 1.6 91 percent, scmad 90 percent(rounded off to nearest integer)
Ankit Garg

Joined: Aug 03, 2008
Posts: 9466

Generally people are confused between servlet path and path info. Anyways, context path is the path on which your application is deployed. Its normally the same as the name of the war file which you deploy. You can get it using request.getContextPath. You can find information about servlet path and path info here and here. I don't know what full path you are talking about...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Łukasz Suchecki
Ranch Hand

Joined: Aug 04, 2009
Posts: 55
Imagine request: http://localhost:8080/myApp/reports/ and url-pattern /reports/*
We have:
- contextPath: /myApp (your app name with / at the begining)
- servletPath: /reports (it's the one defined in url-pattern with / at the begining and without *)
- pathInfo: / (start with / everything in url after sevletPath)

But for url-pattern *.do you have:
- contextPath - the same
- servletPath - /reports/ (because it was matched to the url-pattern)
- pathInfo - null (because there is nothing left after servlet path)
I agree. Here's the link:
subject: contextpath,servlet path and full path
It's not a secret anymore!