File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes problem displaying jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "problem displaying jsp " Watch "problem displaying jsp " New topic
Author

problem displaying jsp

owen fernandes
Greenhorn

Joined: Jun 23, 2004
Posts: 2
only the html code of my JSPs are displaying
it seems as though the java(jsp) code aren't being compiled
<html>
<title> Register</title>
<body>


<p><BIG>
Today's date is <%= new java.util.Date() %>
</h2>
</body>
</html>

with the above code i get
Today's date is
displayed in my browser
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi Owen,

Welcome to JavaRanch!

A JSP is compiled into Java code by a JSP container (typically into a servlet) and then executed by the container; the output of compiled Java code is what gets sent to the browser. If you're just getting the uncompiled JSP in your browser, then perhaps you're not serving it from a JSP container (like Tomcat)? You're not just trying to open the *.jsp file directly using "Open File..." from your browser, are you?


[Jess in Action][AskingGoodQuestions]
Karl Laird
Ranch Hand

Joined: Jul 14, 2001
Posts: 67
Hi Owen,

It would appear that your code fragment is getting compiled - otherwise I would expect to see the "<%= new java.util.Date() %>" in your output...

Possibly what you might want to do is something more along the lines of:

<% myDate = new java.util.Date();
dateFormat = new java.text.SimpleDateFormat("yyyy-mm-dd");
%>
<html>
<title> Register</title>
<body>


<p><BIG>
Today's date is <%= dateFormat.format(myDate) %>
</h2>
</body>
</html>


The Eagle sneers at the Peacock<p>Systems Administrator<br />OrderWare Solutions Ltd<br /><a href="http://www.orderware.net" target="_blank" rel="nofollow">http://www.orderware.net</a>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

It would appear that your code fragment is getting compiled - otherwise I would expect to see the "<%= new java.util.Date() %>" in your output...


Actually, no it won't. The browser will mistake it for an invalid tag and ignore it. It will show up in a 'View Source', but not in the browser output.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
owen fernandes
Greenhorn

Joined: Jun 23, 2004
Posts: 2
i have tomcat 5 and every thing was working fine up to a couple days ago.
and now it just won't work.
i tried reinstalling tomcat and the problem is still there.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Since this is clearly becoming a Tomcat setup issue rather than a JSP technology question, I'm moving this off to the Tomcat forum.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Step #1: Perform some basic debugging. Is the page being translated or not?

Perform a 'View Source' in your browser. Are the JSP scriplet tags still there? If so, the page is not being translated. If they are not, what are they replaced with? Nothing? Poorly formatted HTML?

These are the first things you should be checking for.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem displaying jsp