This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: overriding jspInit() - JSP
 
Similar Threads
Initializing your JSP
Regarding jspInit() overriding
Problem - Configuring init parameters for jsp
Initializing your JSP
question--Initializing JSP