• 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

Doubt about how configuring init parameters in JSP

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

In the pag 308 del HFSJ there is this, for configure servlet init params for a JSP



Doudt 1: What name should go within element <servlet-name>??? the name that servlet produce for Tomcat??? or the name that whatever servlet that i have in my app web???
Doudt 2: How i recover this parameter? I'm try this in my MyTestInit.jsp

But i obtain null. I too try it override servlet's init() method, as such make in the pag 308, but even though that I declare the variable emailAddr like of instance, I continue obtaining null

Thanks
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anais,

1. <servlet-name> can be any meaningful name for that servlet.

2. Include <servlet-mapping> for the <servlet-name> mentioned in web.xml


<servlet-mapping>
<servlet-name>MyTestInit</servlet-name>
<url-pattern>/Test</url-pattern>
</servlet-mapping>

i too had the same error and when i mentioned the above in web.xml it worked fine.


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

For me it is working.

I tried like this

web.xml

<servlet>


<servlet-name>Init</servlet-name>
<jsp-file>/anil/initJsp.jsp</jsp-file>
<init-param>
<param-name>name</param-name>
<param-value>anil kumar</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>Init</servlet-name>
<url-pattern>/first.do</url-pattern>
</servlet-mapping>



JspFile

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>

<h1>JSP Page</h1>

<%
String s=config.getInitParameter("name");

%>
<%=s%>
</body>
</html>


Url:http://localhost:8084/Checking/first.do


Thanks

Anil Kumar
 
Anais Aponte
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, guys

It already works to me perfect
 
reply
    Bookmark Topic Watch Topic
  • New Topic