• 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

implicit object config

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

I am a newbie to the jsp and servlet technology and am trying to teach myself.So sorry for any obvious questions

In the using JSP chapter of head first it says that the servletConfig can be accessed using the implicit object config .
It says using the <jsp-file> inside the servlet tag the init params may be configured how can I access these params in my jsp
ie what can i say in a jsp for getServletConfig().getInitParameter("email");

regards
priya
 
subu ananthram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here are my web.xml file
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>myfile</servlet-name>
<jsp-file>/ct.jsp</jsp-file>
<init-param>
<param-name>panniemail</param-name>
<param-value>bellsouthh.net</param-value>
</init-param>
</servlet>
<context-param>
<param-name>mail</param-name>
<param-value>my mail</param-value>
</context-param>
</web-app>


jsp
<html>
<body>
<%=config.getInitParameter("panniemail")%>
<%=application.getInitParameter("email")%>

</body>
</html>

any help greatly appreciated
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi subu ananthram,

See this thread, it will certainly clear your doubt..

Hint: You can actually override jspinit() and access the config elements of web.xml.
You also need to provide a servlet mapping correspondingly.

Nikhil.
 
Nikhil Menon
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See this thread...
I forgot to add this, sorry for inconvenience

http://forum.java.sun.com/thread.jspa?threadID=511486&messageID=2431292
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,folks
I'm still wondering how to retrive jsp initial parameters by using EL, following is my web.xml for your reference:
....
<servlet>
<servlet-name>TestJspInit</servlet-name>
<jsp-file>/EL/testInit.jsp</jsp-file>
<init-param>
<param-name>email</param-name>
<param-value>ikickedbutt@wickedlysmart.com</param-value>
</init-param>
</servlet>
....
<servlet-mapping>
<servlet-name>TestJspInit</servlet-name>
<url-pattern>/TestJspInit</url-pattern>
</servlet-mapping>
In my /EL/testInit.jsp,I wrote:
${pageContext.config.email}
but it failed and give a error say :
Unable to find a value for "config" in object of class "org.apache.jasper.runtime.PageContextImpl" using operator "."
Anybody can help me clear this? thanks in advance.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic