File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP not working

 
Ray Tam
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have installed Tomcat 4.1.18 successfully on Windows XP Pro. I run the startup.bat in my apache\bin directory and when I key in http://localhost:8080, I get the start page. However, when I try to bring up my JSP page, it is not working.
<html>
<body>
<% out.println ("testing JSP"); %>
<h1>JSP test</h1><br><hr>
</body>
Any idea why this is not working? Thanks in advance.
</html>
 
Paul Stevens
Ranch Hand
Posts: 2823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error are you getting? Where is your jsp paage? What url are you putting in the browser?
 
Ray Tam
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not getting any error. I expected that "Testing JSP" would have shown. I have moved the JSP page to several directories in an effort to make it work. Is there a directory that I need to be in?
 
Ray Tam
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neither suggestions yielded the correct results. I intentionally made typos and it was ignored.
 
Brian Glodde
Ranch Hand
Posts: 171
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP page should be in under the webapps folder. If the JSP, say "yourjsp.jsp" is part of a web application eg "foo", your JSP should be at located in "%CATALINA_HOME%/webapps/foo/yourjsp.jsp" and via URL at http://localhost:8080/foo/yourjsp.jsp
Sorry for the earlier post, was incorrect and in haste.
 
Ray Tam
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The URL is correct since I placed
<h1> My JSP </h1>
before the
<% out.println ("JSP test"); %>
I see that fine. It's the "JSP test" that's not coming out. Is there something that needs to be done prior or is there something missing from the HTML??
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this works fine for me:
And in the generated servlet I get:Not sure why you'd break into a scriptlet just to use the 'out' object though. That's what JSPs were meant to make easy.
 
Dave Jochim
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code that Mike posted works for me as well. Are you looking for 'JSP test' to be printed in the JSP or in the Tomcat window opened with the startup.bat? I may be off here (which is usually the case) but you sounded like you might be looking in the startup.bat window, in which case you need System.out.println().
Again sorry if this is off the mark.
 
Ray Tam
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I swiped this code from a book except for the hard coded literals. I would expect to see on the HTML
Testing JSP
Test JSP
Why would you go to look at the servlet? Thanks.
 
praveen patil
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
just SET
CLASSPATH=.;<TOMCAT_HOME>\COMMOM\LIB\SERVLET.JAR.
also if u r using ur own directory, put it in
classpath. i hope it will work fine now.
Praveen
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic