Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

overriding jspInit() - JSP

 
Mukunthan Shanmuganathan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Mukunthan Shanmuganathan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys!

I fixed it myself!

Thank You.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic