aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Basic JSP problem" Watch "Basic JSP problem" New topic
Author

Basic JSP problem

sai baba
Greenhorn

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?

Thanks
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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
Greenhorn

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?

Sai
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
Bartender

Joined: Jul 06, 2005
Posts: 1018
Suggestions:
Read this: http://tomcat.apache.org/tomcat-5.5-doc/appdev/index.html
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"
[TOMCAT]/webapps/WebProject/WEB-INF/web.xml
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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:
http://localhost:8080/myapp/main.jsp
 
Consider Paul's rocket mass heater.
 
subject: Basic JSP problem