Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

implicit object config

 
subu ananthram
Ranch Hand
Posts: 102
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Nikhil Menon
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
melan hen
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic