File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt about how configuring init parameters in JSP

 
Anais Aponte
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
vidhya jayapalan
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
anil kumar
Ranch Hand
Posts: 447
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, guys

It already works to me perfect
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic