This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes PageContext is not able to get servlet init-param Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "PageContext is not able to get servlet init-param" Watch "PageContext is not able to get servlet init-param" New topic
Author

PageContext is not able to get servlet init-param

Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 596
    
    1

I am trying to get servlet init-param but it returns null.




I am invoking the tag via corresponding jsp.Tld is declared properly.
I am able to get context parameters but the problem is init params.

please help,

best regards,
omi
[ August 30, 2008: Message edited by: omi sharma ]

Most of the programming problems can't be solved because you don't know what the exact problem is.
Defining your problem correctly leads you to the right solution.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

context.getServletConfig()

Which servlet do you think it refers to ?


[My Blog]
All roads lead to JavaRanch
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 596
    
    1

I think it refers to the MovieServlet in which I RequestDispatched to
the jsp where I put the tag.


edited:I considered your hint and I tested the tag class via getServletName() and I surprised to find out it refers jsp.I don't have any servlet named jsp.
I am afraid it refers the jsp where I put the tag because jsp is actually
a servlet.

if this is not a right way then how on earth do I get inits ?

best regards,
omi
[ August 31, 2008: Message edited by: omi sharma ]
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
You can declare a jsp page in a <servlet> tag! E.g.

|<servlet>
| <servlet-name>movieJsp</servlet-name>
| <servlet-class>/jsp/MoviePage.jsp</servlet-class>
| <init-param>
| <param-name>movie-name</param-name>
| <param-value>Crank 2: High Voltage</param-value>
| </init-param>
|</servlet>

Please let me know if this actually works!


SCJP 1.4 (81%)<br />SCWCD 5 (95%)
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 596
    
    1

Jan you tried nice , your code does not work but it reminded me to
do this:



Now , it's working fine.

by the way ,crank 2 been released ,I did not know about it
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
Nope, we have to wait a year for Crank 2

I think my xml was not working because I used <servlet-class> instead of <jsp-file>. The <servlet-mapping> in your code is not necessary I guess.
If you leave it out, it will probably still work..
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 596
    
    1

yea , it's working without mapping.

well ,I can wait for crank 2 ,writing web pages in java.

best regards,
omi
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: PageContext is not able to get servlet init-param
 
It's not a secret anymore!