| Author |
config Implicit Variable - Major Doubt
|
Sandeep Vaid
Ranch Hand
Joined: Feb 27, 2006
Posts: 390
|
|
In Hanumant deshmukh's book [p-205] initTest.jsp File : Now it says that : When JSP page initTest.jsp is accessed as a servlet, using the http://localhost:8080/chapter11/servlet/InitTestServlet it will work fine. Ques 1: How can you access using Servet-Name? Ques 2 : when i define proper servlet-mapping, then i can access it using url-pattern but when i print all the init ariables (not in above code) the output comes as : fork : false xpoweredBy : false <Now proper init varaibles > ? Why extra parms : fork and xpoweredBy ?
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
|
Did you try it actually?? It should have given you a 404...when you try to access using the servlet name instead of the url pattern...
|
SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
|
 |
Stein Vom
Ranch Hand
Joined: Jul 10, 2005
Posts: 78
|
|
You can a servlet directly without url-pattern with urWebApp/servlet/servletName
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Stein...are you sure?? I tried this and gave me 404...
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
I'm using a form action...I got my mistake...yes, you can access the servlet with its name...You are right stein...
|
 |
Stein Vom
Ranch Hand
Joined: Jul 10, 2005
Posts: 78
|
|
|
tell me the exact URL that you are typing and also your servlet file name
|
 |
Stein Vom
Ranch Hand
Joined: Jul 10, 2005
Posts: 78
|
|
|
Ok. . .great
|
 |
Sergio Tridente
Ranch Hand
Joined: Mar 22, 2007
Posts: 329
|
|
Originally posted by Stein Vom: You can a servlet directly without url-pattern with urWebApp/servlet/servletName
Can you point out where did you get this from? Is it in the spces? I am asking because in the exam we won't be tested on tomcat but on what the spec says.
|
SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
|
 |
Darren Weaver
Greenhorn
Joined: Apr 30, 2007
Posts: 7
|
|
|
As for Question 1., in the DD of the particular example you posted, there is an explicit servlet-mapping which happens to match the name of the servlet (prepended with the path /servlet).
|
 |
Rancy Chadha
Ranch Hand
Joined: Jul 12, 2006
Posts: 135
|
|
Hi Sandeep, Darren is right. In your DD you have this:
<servlet-mapping><servlet-name>InitTestServlet</servlet-name><url-pattern>/servlet/InitTestServlet</url-pattern> </servlet-mapping>
and you are using link <a href="http://localhost:8080/chapter11/<i rel="nofollow">servlet/InitTestServlet</i>" target="_blank">http://localhost:8080/chapter11/servlet/InitTestServlet to invoke the JSP. Thus you are not accessing your JSP with the value of <servlet-name> but with the name in <url-pattern>. Thanks, -Rancy
|
Thanks,<br />-Rancy
|
 |
Sandeep Vaid
Ranch Hand
Joined: Feb 27, 2006
Posts: 390
|
|
what i am trying to say is : Suppose i have only defined <servlet> element in web.xml & not <servlet-mapping> as in : then according to the book, i can access my JSP using : http://localhost:8080/<web-app name>/InitTestServlet Note: this is not working. Moreover how can i use a servlet-name to access JSP/servlet ?
|
 |
 |
|
|
subject: config Implicit Variable - Major Doubt
|
|
|