• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to get InitParameter from JSP

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

i cant get get the InitParameter from JSP-page. They sey that the implizit object "config" is for JSP the same as "ServletConfig" for servlets and "application" ist the same as "ServletContext", but i allways getting the null when i try config.getInitParameter.
my jsp

my web.xml

[ September 21, 2005: Message edited by: Ner min ]
 
Ner min
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sill me i forgot this :

<servlet-mapping>
<servlet-name>HelloWorldJSP</servlet-name>
<url-pattern>/SimpleFormHandler.jsp</url-pattern>
</servlet-mapping>
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am also having the same doubt..I reproduced this stuff and it is not printing the servlet init parameter for me too. But gives the config init parameter..
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Only when the application context init parameter and servlet init parameter have the same name the problem occurs. If we change one of the init parameter names it works fine.

As per page no 160, HFSJ, if I give a context init parameter the same name as a servlet init parameter in the same web app, this should not cause any problem.


... because there's no name space conflict since you get the parameters through two different objects(ServletContext or ServletConfig).



Is this a bug in Tomcat5.5.9?


- Gouri
[ September 22, 2005: Message edited by: Gouri Bargi ]
 
Ner min
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gouri,

probably, im running Apache Tomcat 5.0.28 Serve
and as sun i added servlet-mapping it worked for me.
[ September 22, 2005: Message edited by: Ner min ]
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello nermin
I have done the same thing. It is working for me.
WEB.XML
<context-param>
<param-name>x</param-name>
<param-value>y</param-value>
</context-param>
<servlet>
<init-param>
<param-name>x</param-name>
<param-value>y</param-value>
</init-param>
<servlet-name>HelloWorldJSP</servlet-name>
<jsp-file>/a.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>HelloWorldJSP</servlet-name>
<url-pattern>/a.jsp</url-pattern>
</servlet-mapping>

i am requesting like this http:\\localhost:8080\karthik\a.jsp

I AM ABLE TO GET BOTH THE VALUES
 
Ner min
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jeah, for me too but Gouri sounds to have problem mit tomcat 5.5
 
Gouri Bargi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops, my apologies

I messed up the init param name in the code. Now it is working fine for me also.

- Gouri
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah this is definitely a problem with tomcat. I'm using tomcat 4.1.31.
You will face this problem even if the names of init parameters do not match.
 
Ner min
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ba the way i'm wondering way dont u dudes simpliy use the latest stable RI,
which is tomcat 5.0 series. U would avoid those tinny problems
 
reply
    Bookmark Topic Watch Topic
  • New Topic