permaculture playing cards*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes implicit object config 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 "implicit object config" Watch "implicit object config" New topic
Author

implicit object config

subu ananthram
Ranch Hand

Joined: May 16, 2004
Posts: 102
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

Joined: May 16, 2004
Posts: 102
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
Nikhil Menon
Ranch Hand

Joined: Nov 22, 2004
Posts: 70
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

Joined: Nov 22, 2004
Posts: 70
See this thread...
I forgot to add this, sorry for inconvenience

http://forum.java.sun.com/thread.jspa?threadID=511486&messageID=2431292
melan hen
Greenhorn

Joined: Feb 14, 2005
Posts: 17
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.


SCJP 1.2 (88%)<br />SCWCD 1.4 (89%)<br />SCBCD (in progress)<br />SCEA (in progress)
 
Don't get me started about those stupid light bulbs.
 
subject: implicit object config