GeeCON Prague 2014*
The moose likes Servlets and the fly likes Servlet Container Root Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Container Root" Watch "Servlet Container Root" New topic
Author

Servlet Container Root

Nirmal Mekala Kumar
Ranch Hand

Joined: Aug 27, 2005
Posts: 63
I have read the following in J2EE documentation for HttpResponse.sendRedirect()
Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root.

can you tell me what servlet container root means. Is it the Catalina Home directory. Or my Tomcat webapps directory?


Nirmal Kumar<br />If you have to aim, aim for the moon. Even if you miss you will land among the stars
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

Originally posted by Nirmal Mekala Kumar:
Is it the Catalina Home directory. Or my Tomcat webapps directory?


Neither.

The servlet container root does not correspond to any physical folder. Rather, it it is the root of all web apps loaded in the system. Many of these apps may be within the webapps folder, so you might think that it corresponds to that folder, but it doesn't really.

A web app does not have to be in webapps and be configured elsewhere on the system (I routinely do this because I want more control over deployment than Tomcat gives me). These apps too are relative to the servlet context root.

The easiest way to interpret this is that the path is expected to contain the context path of the targetted web application.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Bear Bibeault wrote:
The servlet container root does not correspond to any physical folder. Rather, it it is the root of all web apps loaded in the system. Many of these apps may be within the webapps folder, so you might think that it corresponds to that folder, but it doesn't really.


I did not understand the part "it it is the root of all web apps loaded in the system". How to visualize this root ? What is the meaning of root ?

Bear Bibeault wrote:
A web app does not have to be in webapps and be configured elsewhere on the system (I routinely do this because I want more control over deployment than Tomcat gives me). These apps too are relative to the servlet context root.


Can you give me an example of a simple app that was made using your approach ? It is new to me. Also, why do books and tutorials tell us to put it in web-apps folder and not like your way ? Will it create difficulties for newbies (like me) ?

Bear Bibeault wrote:
The easiest way to interpret this is that the path is expected to contain the context path of the targeted web application.


Please tell me what is this "context path" ?

PS : 2011, long time....


SCJP 6. Learning more now.
Rick Roberts
Ranch Hand

Joined: Apr 07, 2005
Posts: 59

Hmmm.... where to begin?
Tomcat Context Reference

I also saw an interesting thread here:
ROOT Context Discussion

HTH,
Rick


SCJP
"Stay on the path."
 
GeeCON Prague 2014
 
subject: Servlet Container Root