It's not a secret anymore!*
The moose likes Tomcat and the fly likes jsp code wont run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "jsp code wont run" Watch "jsp code wont run" New topic
Author

jsp code wont run

andrew bliss
Greenhorn

Joined: Dec 09, 2008
Posts: 12
I am new to Tomcat/Apache. I have installed Tomcat, and I have written a simple jsp page.

<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>

But that is how it renders in the browser. How do I make apache/tomcat run the jsp?
Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
Originally posted by andrew bliss:
I am new to Tomcat/Apache. I have installed Tomcat, and I have written a simple jsp page.

<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>

But that is how it renders in the browser. How do I make apache/tomcat run the jsp?

This is due to the fact that your code is not being interpreted by the JSP engine. Did you place the jsp file in the webapps/ROOT/ directory? And, have you started the tomcat server? This can be tested by entering http://localhost:8080/ in your browser.


SCJP 1.4 85%
andrew bliss
Greenhorn

Joined: Dec 09, 2008
Posts: 12
Thanks for the reply. I probably should have given more detail. So my friend has a ubuntu server that is running two websites on it. His and mine. He said that the localhost:8080 worked and that it showed up with the tomcat page. But when I access it on the web it shows up like normal text. And he is busy at work so I can't really see what his localhost:8080 is doing.
Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
Originally posted by andrew bliss:
And he is busy at work so I can't really see what his localhost:8080 is doing.

It's a little unclear from your post to know if you have physical access to your friend's ubuntu server. The localhost will not work from the web. You have to know the website's domain name too.
andrew bliss
Greenhorn

Joined: Dec 09, 2008
Posts: 12
I don't have physical access to the server.
Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
I am afraid the "localhost:8080" won't work unless you are accessing the server remotely through VNC or some other software. You will need the hostname/IP to access the website.
andrew bliss
Greenhorn

Joined: Dec 09, 2008
Posts: 12
I can access the server remotely but I only have access to a shell and not a gui. I was just wondering why the jsp wouldn't run when I access the website on the internet.
Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
You can get the IP address of the remote machine with ifconfig -a and use the ip-address:8080 instead of the localhost:8080. I am assuming that both the computers are in the same network, and hence recognize each other.
andrew bliss
Greenhorn

Joined: Dec 09, 2008
Posts: 12
Our computers are not on the same network.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Just a checklist
1. How do you access your JSP that is present on your friend's PC.
This hardly matters how the concern is you can access it.

2. your JSP has a .jsp extension.
Currently it might be .htm or .html so it is rendered as plain text.

3. When you get the Tomcat homepage, you are able to browse through the JSP Examples.


SCJP, SCWCD.
|Asking Good Questions|
andrew bliss
Greenhorn

Joined: Dec 09, 2008
Posts: 12
1. I type in his internet site. http://www.totallyghettogames.com/test/test.jsp

2. It does have a jsp extension

3. I don't have access to the tomcat page, I only have access to a remote shell to his server, but he says that it does come up with the tomcat page
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Are you sure that the "test" directory is configured as a web application with a WEB-INF sub-directory and web.xml deployment descriptor?

Bill
andrew bliss
Greenhorn

Joined: Dec 09, 2008
Posts: 12
How do I check that?
andrew bliss
Greenhorn

Joined: Dec 09, 2008
Posts: 12
Ok so I have learned a little more about this. I have gotten it to work on the localhost:8080. But my main question is how do I get it to work with a website. My website is http://www.hitlessons.com/test/test.jsp So I have looked at the mod_jk connector. But from looking at the documentation I am not sure how to use it. Apache is using virtual hosting so this website is one of many. Do I need to edit the apache conf file and make a worker or something to forward jsp requests to tomcat? I am really not sure what to do. Thanks for the help.
 
jQuery in Action, 2nd edition
 
subject: jsp code wont run
 
Similar Threads
JSP not working
servlet not running but examples does
JWeb+ Question ID :997026825290
Urgent
compile jsp in tomcat