File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Basic JSP problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Basic JSP problem" Watch "Basic JSP problem" New topic

Basic JSP problem

sai baba

Joined: Apr 26, 2004
Posts: 9
Hi I have just installed tomcat on my windows xp machine.I downloaded the Apache-Tomcat version 5.5.15(windows executable) and also the jdk 5.0.
When I enter http://localhost:8080/ into the browser, I get the tomcat Jakarta page-no problem.

When I try my first test jsp page (main.jsp)with the follwing expression in the body section of the jsp page:
Hello! The time is now: <% = new java.util.Date() %>

I get the same line in my webpage:
Hello! The time is now: <% = new java.util.Date() %>

The java expression is not evaluated, no error messages.
Anyone have any suggestions what I should be doing?

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

First, you've got an extra space between the % and the =.
You should remove it.

What file did you put this line in ? (filename and directory)

[My Blog]
All roads lead to JavaRanch
sai baba

Joined: Apr 26, 2004
Posts: 9
Hey Thanks for the help,
I have the file main.jsp in a WebProject folder which is a subfolder of the Tomcat Root folder(Root/WebProject/main.jsp).

From what little I know its supposed to be a simple test. I have no servelet in the page so am I still to have created WebProject\WEB-INF\web.xml? If so what will it contain in the servlet tag? I have not edited any other XML files.

Any Ideas/Suggestions?

Ben Zung
Ranch Hand

Joined: Mar 25, 2004
Posts: 109
As Satou pointed out, you have extra space in around the "=". And to answer you last question, I don't think you have to have web.xml in place for your page has no servlets and you don't need any parameters set etc. Also, instead of "root", I'd put it under "webapps", say "webapps/app1/main.jsp". Then http://your_ip:8080/app1/main.jsp should work. If not use Tomcat manager and do a "reload" should make you happy.

Good luck.
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
Read this:
Particularly the sections on Deployment/source organization.

The ROOT directory, is an already existing webapp. You should not have a directory ROOT/WebProject/WEB-INF.

WEB-INF directories should only be in a directory directly under webapps.
eg to define a web application "WebProject"
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

You don't need web.xml yet, but you should deploy your application under webapps, not ROOT. Create a new directory (e.g. myapp) under webapps, and put your main.jsp file in it. Access it with:
subject: Basic JSP problem
It's not a secret anymore!