Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

request URI doubt?

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

The question below,

When the context path is defined as /furniture and the servlet called search, which options best describes the result returned from the getPathInfo() method?

/furniture/tables/search?type=kitchen

1) ""
2) /search
3) /search?type=kitchen
4) null

The answer given as null???


Guys what it means by saying context path and root and home with respect to web applications?? I always get lost in questions of this type!
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That URL does not contain any extra path info. This one:



would have

"/type/kitchen" as path info.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getPathInfo() returns extra path info and it is the path between servlet and query string. In your example there is nothing between "search" and "?type=kitchen", so it is null.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Ulf & Sri,

Thanks for the help! I understood getPathInfo()!
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

Still I'm dubious about what it means by saying context root and document root?? Can anyone clarify this...probably with a small example?
 
Sri Kan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Document root is where you keep your web files and it is an absolute path on your file system. Context root is a kind of virtual directory for web users to access web files.

Ex:
Web Server/Servlet Container - Tomcat

You can place all your web files (html,jsp, classes etc.) in C:\MyProject directory and it is your document directory. You specify this in Tomcat configuration.
In Tomcat configuration file you can specify "/myweb" as context root of your web application. Web users access this application with something like "http://myweb/...".
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Document root is not explained in the Servlet specs, nor the Context root.
2. All authors speak about Context path.
3. But, Manning publication speaks about Document root. For example, if the webapps directory contains three web applications, like, app1, sampleapp and helloapp, helloapp directory is the document root for the helloapp web application.
4. From my understanding, this is the same as Context root / Context Path.
5. For a servlet mapped to /path in the application with context root myapp:

http://www.domain.com:80/myapp/path/resource?name=value
http://www.domain.com]www.domain.com --------> Host
/myapp --------> Context Path
/path --------> Servlet Path
/resource --------> Path Info
name=value --------> Query String

6. The above example is available on Page 68 of Charles Lyons book, which
is similar to example by Mikalai Zaikin's notes.

7. The above mentioned book also says that getContextPath(), getPathInfo(),
getRequestURI(), getServletPath() etc. are NOT in exam objectives.

[ April 23, 2007: Message edited by: Sunder Ganapathy ]
[ April 23, 2007: Message edited by: Sunder Ganapathy ]
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sunder for the clarification!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic