Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem displaying jsp

 
owen fernandes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Karl Laird
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
owen fernandes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic