• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Hanuman Deshmukh Chapter 12 Question..

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in chapter 12 of hanuman deshmukh book,i have
web.xml configured like below,

and when i use, the following two cases, iam getting the same result,
1. http://localhost:8080/chapter12/servlet/ InitTestServlet
2. http://localhost:8080/chapter12/initTest.jsp
and if i use below request, iam getting 404 error
3. http://localhost:8080/chapter12/InitTestServlet
is it the <jsp-file>/initTest.jsp</jsp-file> element that is making the difference.i dont understand this jsp-file element for this case at all.
and what is the /servlet/ code in first case doing?

Waiting for your replies.
Thanks.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello;
If you don't use the mapping your JSP engine will create two different instances. which explain the fact of having two different results by using the above URLs. However the web.xml you are using already has the mapping in, try to take the statement of mapping off, save the file and restart Tomcat, and then try again, you'll see at that time two different results.
take care
 
viswanath sastry
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If you don't use the mapping your JSP engine will create two different instances. which explain the fact of having two different results by using the above URLs. However the web.xml you are using already has the mapping in, try to take the statement of mapping off, save the file and restart Tomcat, and then try again, you'll see at that time two different results.


Thanks,
i know why case 2 is working, because there is a servlet mapping. idont have a problem with that.but why is case 1 giving the same result? and how is it different from case 3(which i know should not work as expected)?my only problem is what makes case 1 give the same result as case 2.?
Thanks.
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
quote: viswanath
-------
"and when i use, the following two cases, iam getting the same result,
1. http://localhost:8080/chapter12/servlet/ InitTestServlet
2. http://localhost:8080/chapter12/initTest.jsp"
--------------------------------------------------
No 1)This is the "registered servlet name".
Most servers(tomcat) have a default URL for servlets :..../webapplication/servlet/ServletName.
When you don't use servlet-mapping to access a registered or unregistered servlet then you have to use "servlet" (Invoker Servlet) entry in the URL.
If u want u can disable the Invoker Servlet so that only custom URLs can access servlets.

No 2) This is the real name and location of the jsp page (so no problem)

No 3). http://localhost:8080/chapter12/InitTestServlet
Although this is the servlets registered name but
1,u can't access it without "servlet" entry.
2, your (servlet-mapping) url-pattern is /initTest.jsp if it was /InitTestServlet it would have worked.
NOTE:
Initialization parameters r only available when servlets r accessed by means of their registered names or through custom url patterns associated with their registered names.
 
Amer Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
quote: viswanath
-------------------------------------
my only problem is what makes case 1 give the same result as case 2.?
--------------------------------------------
Same servlet class!!!
 
viswanath sastry
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Amer,
This was a new concept for me.i haven't read about invoker servlets in scwcd study kit(the book only mentions steps in appendix to make invoker servlet work and no where else)
My question is , will there be questions regarding invoker servlet in scwcd exam?
 
Amer Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
quote viswanath
My question is , will there be questions regarding invoker servlet in scwcd exam?
----------------------------------------------

I did'nt get any!
check this!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic