File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes overriding jspInit() - JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "overriding jspInit() - JSP" Watch "overriding jspInit() - JSP" New topic
Author

overriding jspInit() - JSP

Mukunthan Shanmuganathan
Ranch Hand

Joined: Jul 24, 2007
Posts: 32
Hi Guys!

Can you tell me What the wrong thing I did in order to view the init param?

My code is as follows,

web.xml
=======

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app >

<servlet>
<servlet-name>test</servlet-name>
<jsp-file>/result.jsp</jsp-file>

<init-param>
<param-name>email</param-name>
<param-value>xyz@yahoo.com</param-value>
</init-param>
</servlet>

</web-app>

result.jsp
==========
<html>
<body>
<%!
public void jspInit() {

ServletConfig sConfig = getServletConfig();

String emailAddr = sConfig.getInitParameter("email");

ServletContext ctx = getServletContext();

ctx.setAttribute("mail",emailAddr);

}
%>


<%= "Thiri's Email is " + getServletContext().getAttribute("mail") %>

</body>
</html>

Thank You
:roll:


Dare to know!
Mukunthan Shanmuganathan
Ranch Hand

Joined: Jul 24, 2007
Posts: 32
Guys!

I fixed it myself!

Thank You.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: overriding jspInit() - JSP