Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Access Servlet InitParameters in JSP

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please tell me how to access the servlet init parameters in the jsp.

I have tried with this,but its always returning null.


Thanks in Advance

Vineela
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we have servlet-class and jsp-file both in servlet tag?
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please remove the <servlet-class> tag line.the class created by the jsp gets all the info passed in thie servlet element.

bye
Kumar
 
Kumar J
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
we are having jsp-file and servlet-name in the servlet element to configure the jsp...to pass init parameters...to say apply everything there is to the servlet that gets created by this jsp.

kumar
 
Vineela Devi
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kumar,

I have removed the <servlet-class> tag.But even then its returning null value.Can u give me a small example of exactly how to get those values.


Thanks in Advance
Vineela
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try restart your application server after modify web.xml file!
 
Gavin Zhao
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it seems no problem after delete <servlet-class>tag,try again!
 
Vineela Devi
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have restarted my server after removing <servlet-class> tag.But still Iam getting null.
Anyone please help me out.

Vineela
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vineela,

I read your problem last week and did a quick test to see if I got the same results. I didn't so see if you can spot any difference to what I did.

I'm using Tomcat 5.0.28



Heres the JSP:



I put my code here:

copy web\result.jsp c:\jakarta-tomcat-5.0.28\webapps\steven-jsp-II-examples\result.jsp



Can you spot any differences?

Steven
[ May 03, 2005: Message edited by: Steven Hoodless ]
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I know it'd been a while since you posted this query - hope it must be resolved by now.

Anyways, I have the solution, posting it for the records -

What you also need to do apart from adding the servlet tag with the init parameters is to add a servlet mapping for the jsp. The mapping could be the same as you are already using to access the url.

Add this to your DD / web.xml and it should work:

<servlet-mapping>
<servlet-name>ServletTest</servlet-name>
<url-pattern>/FirstJsp.jsp</url-pattern>
</servlet-mapping>

I couldn't quite figure out why this is necessary - if you do happen to know the answer, just let me know.

Thanks,
 
reply
    Bookmark Topic Watch Topic
  • New Topic