Page 1 of 1
About Question enthuware.jwpv6.2.1121 :
Posted: Wed Feb 18, 2015 6:57 am
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");
Re: About Question enthuware.jwpv6.2.1121 :
Posted: Wed Feb 18, 2015 8:11 am
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.
Re: About Question enthuware.jwpv6.2.1121 :
Posted: Wed Feb 18, 2015 9:11 am
by Ambiorix
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.
Re: About Question enthuware.jwpv6.2.1121 :
Posted: Wed Feb 18, 2015 9:21 pm
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.
Re: About Question enthuware.jwpv6.2.1121 :
Posted: Sun May 22, 2016 4:55 pm
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 ?
Re: About Question enthuware.jwpv6.2.1121 :
Posted: Sun May 22, 2016 11:02 pm
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 "".
Re: About Question enthuware.jwpv6.2.1121 :
Posted: Mon May 23, 2016 7:16 pm
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
Re: About Question enthuware.jwpv6.2.1121 :
Posted: Mon May 23, 2016 8:22 pm
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.