• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

config Implicit Variable - Major Doubt

 
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can a servlet directly without url-pattern with

urWebApp/servlet/servletName
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stein...are you sure?? I tried this and gave me 404...
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
tell me the exact URL that you are typing and also your servlet file name
 
Stein Vom
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. . .great
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
reply
    Bookmark Topic Watch Topic
  • New Topic