It's not a secret anymore!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes question--Initializing JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "question--Initializing JSP" Watch "question--Initializing JSP" New topic

question--Initializing JSP

Anna Wang
Ranch Hand

Joined: May 26, 2006
Posts: 30

In HFSJ (p. 308), about initializing JSP, I am not very clear about that. How can I do servlet initialization stuff in JSP.

I wrote part of the codes, can anybody add more to finish it.

From the book and errara.
The web.xml is:
<web-app xmlns=""
xsi:schemaLocation="" version="2.4">


TestInit.jsp is:

public void jspInit() {
ServletConfig sConfig = getServletConfig();
String e = sConfig.getInitParameter("email");
ServletContext ctx = getServletContext();
ctx.setAttribute("mail", e);

The email address is: ???


How to write next to output:

Thank you very much.

Gaurav Gambhir
Ranch Hand

Joined: Mar 04, 2006
Posts: 256
Related Thread
Karne Reddy
Ranch Hand

Joined: May 28, 2006
Posts: 35
Hi Anna,
U can print the email by


If u have not ovverrided the jspInit() method , u can display it
by <%=config.getInitParameter("email")%>
(config is implicit varialble)

Anna Wang
Ranch Hand

Joined: May 26, 2006
Posts: 30
Thank you very much for the answers. It is very clear.

salil verma

Joined: Jun 03, 2006
Posts: 22
Hi Karne,
applicationScope is a map of attribures of context so ${applicationScope.mail} would not work for printing the config parameters.
although <%=config.getInitParameter("email")%> will fairely work
I agree. Here's the link:
subject: question--Initializing JSP
It's not a secret anymore!