File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access Servlet InitParameters in JSP

 
Vineela Devi
Ranch Hand
Posts: 191
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Bhumika Thakkar
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we have servlet-class and jsp-file both in servlet tag?
 
Kumar J
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Gavin Zhao
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try restart your application server after modify web.xml file!
 
Gavin Zhao
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it seems no problem after delete <servlet-class>tag,try again!
 
Vineela Devi
Ranch Hand
Posts: 191
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Steven Hoodless
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Nash Jetts
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • 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,
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic