• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Container Root

 
Nirmal Mekala Kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
Rick Roberts
Ranch Hand
Posts: 59
Hibernate Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm.... where to begin?
Tomcat Context Reference

I also saw an interesting thread here:
ROOT Context Discussion

HTH,
Rick
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic