File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem - Configuring init parameters for jsp

 
Anuradha Prasanna
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Siva Masilamani
Ranch Hand
Posts: 385
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
Anuradha Prasanna
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, that's cool. As long as you aware of what's outdated and what's not.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic