File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSP" Watch "JSP" New topic
Author

JSP

Kashyap Hosdurga
Ranch Hand

Joined: Sep 19, 2005
Posts: 83
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
Priya Jothi
Ranch Hand

Joined: Jul 13, 2004
Posts: 168
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.
Nicky Eng
Ranch Hand

Joined: Mar 26, 2005
Posts: 378
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 ]

From NickyEng
Diploma in Computer Studies
SCJP 1.4
SCWCD 1.4
Formula 1 app by Maxis (Playbook)
Troy Peter
Greenhorn

Joined: Oct 13, 2005
Posts: 14
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
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
// edit ---> why you put your jsp file into tomcat/webapps/ROOT directory ???

why not? :roll: :roll:


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Kashyap Hosdurga
Ranch Hand

Joined: Sep 19, 2005
Posts: 83
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

Joined: Oct 13, 2005
Posts: 14
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP
 
Similar Threads
JSP and XML
JSP error
JSTL C:out (Beginners level)
Including a JSP page from a different Web Application
Stuck on HelloWorldServlet