Meaningless Drivel is fun!*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt about how configuring init parameters in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt about how configuring init parameters in JSP" Watch "Doubt about how configuring init parameters in JSP" New topic
Author

Doubt about how configuring init parameters in JSP

Anais Aponte
Greenhorn

Joined: Jul 24, 2007
Posts: 8
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


Anais Aponte
vidhya jayapalan
Greenhorn

Joined: Jul 14, 2005
Posts: 12
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
anil kumar
Ranch Hand

Joined: Feb 23, 2007
Posts: 447
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

Joined: Jul 24, 2007
Posts: 8
Thanks, guys

It already works to me perfect
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt about how configuring init parameters in JSP