About Question enthuware.jwpv6.2.1121 :

Moderator: admin

Post Reply
Ambiorix
Posts: 25
Joined: Thu Jan 10, 2013 8:45 am
Contact:

About Question enthuware.jwpv6.2.1121 :

Post by Ambiorix »

Why is option 2 wrong?
It is accessible to all the servlets of all the webapps of the container.
Surely, provided it's in the same container, I can get a handle on another app's ServletContext and get its init parameters as normal?

Code: Select all

getContext("some_foreign_context").getInitParameter("param_name");

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1121 :

Post by admin »

Are you referring to this: http://docs.oracle.com/javaee/6/api/jav ... ng.String)

Its description includes - "In a security conscious environment, the servlet container may return null for a given URL."

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Ambiorix
Posts: 25
Joined: Thu Jan 10, 2013 8:45 am
Contact:

Re: About Question enthuware.jwpv6.2.1121 :

Post by Ambiorix »

admin wrote:Are you referring to this: http://docs.oracle.com/javaee/6/api/jav ... ng.String)

Its description includes - "In a security conscious environment, the servlet container may return null for a given URL."

HTH,
Paul.
Yes. To me that says the vendor is free to choose whether they want to allow access to other apps in the container or not. It certainly doesn't say that it must return null.

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1121 :

Post by admin »

No, the "may" here means that an application may have security applied to it and in that case the container will return null if another application tries to access its context information.
If you like our products and services, please help us by posting your review here.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1121 :

Post by himaiMinh »

Hi, in the explanation,
Servlet in a container that were not deployed as part of a web application...
I think a servlet is deployed in a web application , packaged in .war file.
How can we deploy a servlet without being in .war ?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1121 :

Post by admin »

You are trying to interpret half of the sentence that is why it doesn't make sense. The full sentence is, "Servlets in a container that were not deployed as part of a web application are implicitly part of a "default" web application".
For example, in tomcat, there is a ROOT directory where you can configure such servlets. They are all considered part of the "default" web app. Context path for such servlets is "".
If you like our products and services, please help us by posting your review here.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1121 :

Post by himaiMinh »

Hi, Paul. Thanks for your reply.
So, you mean the servlet, org.apache.cataline.servlets.DefaultServlet that is configured in conf/web.xml is default servlet?
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
Can I create my own servlet , put it in the root directory and configure it in conf/web.xml ?

Reference:
https://tomcat.apache.org/tomcat-7.0-do ... rvlet.html

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1121 :

Post by admin »

No, it is talking about default application (not default servlet). When you deploy your war file, you associate that application with a name. But there is an application with no name. That is the default application. In tomcat, this application resides in webapps\ROOT folder. There is no war file for this app. Any servlet that is not part of any app, can be put here without being inside a war file.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests