aspose file tools*
The moose likes JSP and the fly likes Problem - Configuring init parameters for jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem - Configuring init parameters for jsp" Watch "Problem - Configuring init parameters for jsp" New topic
Author

Problem - Configuring init parameters for jsp

Anuradha Prasanna
Ranch Hand

Joined: Mar 09, 2006
Posts: 115
I have a jsp(BasicCounter.jsp) in my C:\tomcat\tomcat-6.0.24\webapps folder,



And in my "web.xml" iam doing the following for configuring the init parameters,

<web-app ...>
<!-- Configuring servlet init parameters for jsp-->
<servlet>
<servlet-name>MyBasicCounter</servlet-name>
<jsp-file>/BasicCounter.jsp</jsp-file>
<init-param>
<param-name>email</param-name> //line 2
<param-value>ikickedyou@wickedlysmart.com</param-value> /line 3
</init-param>
</servlet>

</web-app>


When i load the jsp page as, "http://localhost:8080/BasicCounter.jsp", i get

The page count is: 2
goodforme@yahoo.co.in


Can you please tell me why my init parameter, "email" is not coming correctly in line 1, as i configured it in line2 and line 3
anyone can you correct me so i can get the value for "email" correctly?
Iam a beginner in jsp.


SCJP 6.0 90%
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Because you are a beginner in JSP You should know that what you are are doing is old old old technology!

It's 2010 -- no Java code should be placed in JSPs. That was discredited over 8 years ago.

I'd focus my attention on modern JSP using the JSTL and EL, and no Java scriptlets.

If you are using a tutorial or a book to learn JSP, you are going to need to trade it for one that's more up to date.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
try recycling your server.

Also this line is not guaranteed to run ServletContext ctx = getServletContext(); because your jsp page extend a servlet that implements HttpJspPage interface which extends Servlet interface.

In all those hierarchy like HttpSJspPage and Servlet interface there is no method called getServletContext().So it is better if you get the context using ServletContext contex=getServletConfig().getServletContext().


SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
Anuradha Prasanna
Ranch Hand

Joined: Mar 09, 2006
Posts: 115
Iam learning jsp from "Head First Servlets & JSP" by "Bryan Basham, Kathy Sierra & Bert Bates"

Actually, chapter 7 focus on basic JSP, then next chapters comes the Scriptless JSP, JSTL and Custom Tag development, as iam in chapter 7, i was just doing the exercise given in that chapter, according to the book, i should get the correct output for the above codes. But iam not getting.
So i turned to help in the JSP forum

I know my JSP is outdated, soon i will learn the latest one.
Meanwhile can anyone modify the code above and tell me how to configure init parameters for your jsp and access the init parameters in your jsp, using the latest JSP(without java code)?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

OK, that's cool. As long as you aware of what's outdated and what's not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem - Configuring init parameters for jsp