• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I am trying to learn JSP and Servlets.
I have a question

I installed Tomcat in my PC. I am able to access local host (http://localhost:8080/index.jsp).

I wrote (rather copied ) a small piece of code

<html>
<body>
<h3> Hello ${param.userName} </h3>
</body>
</html>

and when i try to access this page using the url
http://localhost:8080/hi.jsp?userName=Kashyap

I get
Hello ${param.userName}
in bold.
What should I do to get the output as

Hello Kashyap.

Also where should I copy my jsp file. Currently it is in
C:\Program Files\Apache Group\Tomcat 4.1\webapps\ROOT

Any help is appreciated.

Thanks,
Kashyap
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have tried the same sample & it is working for me!!.Donno whatz wrong in urs.btw what version of tomcat are you using?.

Regards,
Priya.
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi there,

// edit ---> why you put your jsp file into tomcat/webapps/ROOT directory ???

1.create a folder named "test", put under Tomcat/webapps/ directory.

2.put your hi.jsp into your "test" folder.

i was wondering your param value is taken from where? from a form inside hi.jsp ???
[ October 13, 2005: Message edited by: Nicky Eng ]
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kashyap,

I'm assuming you're using Tomcat 4.1. Please use Tomcat 5.0. This is the version that implements specs Servlet 2.4 and JSP 2.0 which is what's covered for the SCWCD.

I'm guessing that expression language (EL) was not part of the previous specs so your server is not aware of them and cannot evaluate ${...}.

Good luck,

Troy
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

// edit ---> why you put your jsp file into tomcat/webapps/ROOT directory ???


why not? :roll: :roll:
 
Kashyap Hosdurga
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Thanks for your replies. But still I am unable to get the desired output.

I installed jakarta-tomcat-5.0.0.exe
Then I tried to access hi.jsp saved in my
C:\Program Files\Apache Group\Tomcat 5.0\webapps

using
http://localhost:8080/hi.jsp?userName=Kashyap

But I am getting

HTTP Status 404 - /hi.jsp

type Status report

message /hi.jsp

description The requested resource (/hi.jsp) is not available.

Apache Tomcat/5.0.0

Please let me know if I am missing anything.

Thanks,
Kashyap
 
Troy Peter
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kashyap,

I think you're on the right track. Unfortunately, there's one little step you missed: tomcat 5 requires that you create a directory for your web application (referred to as the context root, or document root, used to resolve URLs). So in your case, you have Tomcat 5.0\webapps, add something like myFirstApp and move your hi.jsp file in that directory, and try again.

So, resource "hi.jsp" should be in:
C:\Program Files\Apache Group\Tomcat 5.0\webapps\myFirstApp

If this works, just remember that whenever you have a new application, you should have a "context root" directory name under webapps when working with tomcat 5 (and higher). This is all nicely explained in the HFSJ book which I'm currently reading.

Good luck,

Troy
 
reply
    Bookmark Topic Watch Topic
  • New Topic