aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Access Servlet InitParameters in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Access Servlet InitParameters in JSP" Watch "Access Servlet InitParameters in JSP" New topic
Author

Access Servlet InitParameters in JSP

Vineela Devi
Ranch Hand

Joined: Dec 20, 2003
Posts: 191
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

Joined: Apr 18, 2005
Posts: 79
can we have servlet-class and jsp-file both in servlet tag?


SCBCD (Preparing) <br />SCWCD, 82%<br />SCJP, 90%
Kumar J
Ranch Hand

Joined: Feb 13, 2005
Posts: 35
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


With Regards,<br />Kumar J
Kumar J
Ranch Hand

Joined: Feb 13, 2005
Posts: 35
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

Joined: Dec 20, 2003
Posts: 191
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

Joined: Apr 29, 2004
Posts: 11
try restart your application server after modify web.xml file!


Impossible Is Nothing!
Gavin Zhao
Greenhorn

Joined: Apr 29, 2004
Posts: 11
it seems no problem after delete <servlet-class>tag,try again!
Vineela Devi
Ranch Hand

Joined: Dec 20, 2003
Posts: 191
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

Joined: Mar 23, 2004
Posts: 64
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 ]

SCJP, SCJD, SCWCD.
Nash Jetts
Greenhorn

Joined: Apr 22, 2005
Posts: 4
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,


Nash Jetts,<br />SCJP 1.4, SCWCD (on-my-way!)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access Servlet InitParameters in JSP
 
Similar Threads
how to get jsp init params
Why this code to get Init Param in JSP not work?
init parameter from jsp
EL- getting JSP Init Param
Need to Configure Servlet Init Parameters for the jsp