This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Default servlet context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Default servlet context" Watch "Default servlet context" New topic
Author

Default servlet context

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi,

What is callws default servlet context?


Assuming that the servlet container is distributed across multiple JVMs, which of the following statements are correct?

Options:

Select 2 correct options.

A separate instance of a non-default servlet context will be available on each of the JVMs.

A separate instance of all servlet context will be avaible on each of the JVMs

The default servlet context will be present only on one of the JVMs.

There is only one instance of servlet contexts across all the JVMs.

None of the above.


Source: Jdiscuss

Thanks,


cmbhatt
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi Chandra


I think that

A separate instance of a non-default servlet context will be available on each of the JVMs.

I am not really shore what means "A separate instance of all servlet context" ?

Regards,
M


SCJP, SCJD, SCWCD, OCPJBCD
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
I am not really shore what means "A separate instance of all servlet context" ?


It means all including the default app, so its not true.

Even this is right
The default servlet context will be present only on one of the JVMs.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Does it mean that there can be a custom ServletContext in a web application?


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218
Chandra about your question,

There is always a default web application, its context is the
default ServletContext.

Generally its the app that is served when you dont specify the context path
(I am not sure if the spec guarantees it).

for tomcat the application under webapps/ROOT is the default webapp.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by Mihai Radulescu:

I am not really shore what means "A separate instance of all servlet context" ?



There is a ServletContext per web application. Thats why it would have been "A separate instance of all servlet context".

As Amol said, there would be a default web application which serves the homepage when you just start the server and dont specify ant specific context root.

Say, for example, in case of Tomcat it would be "http://localhost:8080" (assume port number is not modified) it will serve the default web application present in the "TOMCAT_INSTALL_DIR/webapps/ROOT".

Does it help?
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Thanks Mihai, Amol & Raghavan,

The correct answers to that question were:


1- A separate instance of a non-default servlet context will be available on
each of the JVMs.

2- The default servlet context will be present only on one of the JVMs.


I am also not sure but think like "default servlet context is given by the
container that is root of the web app and because servlet context is not
shared across JVM like session (we have sessionDidActivate and sessionWillPassivate methods from the HttpSessionListener)".


Amol and Raghavan, I got your points.

Thanks,
[ August 10, 2007: Message edited by: Chandra Bhatt ]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by Chandra Bhatt:
I am also not sure but think like "default servlet context is given by the container that is root of the web app and because servlet context is not shared across JVM like session (we have sessionDidActivate and sessionWillPassivate methods from the HttpSessionListener)".


Chandra, Your guess sounds reasonable!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Default servlet context
 
Similar Threads
mock question regarding distributed application across multiple JVMs
Defaul ServletContext ...??? Question
Servlet context
Multiple JVMs (default vs. non-default servlet context)
distributed across multiple JVM