Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2003, 08:27 PM
Registered User
 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Having Problem with Tomcat and/or JDK

I downloaded and installed the Tomcat server. Then changed by system settings on my windows 98 machine and restarted my machine. But when I run a simple JSP (with in it <% new java.util.Date() %>, everything that is straight html appears. I know there has to be a simple answer to this.

 
Old July 9th, 2003, 12:11 PM
Authorized User
 
Join Date: Jun 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jwenting Send a message via MSN to jwenting
Default

You need to be a bit clearer here, what exactly is going wrong (or what do you expect to happen and what do you observe to happen)?
 
Old July 9th, 2003, 02:53 PM
Registered User
 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The following code :
<html>
  <head>
    <title>My First JSP</title>
  </head>

  <body>
    Hello world!<br>
    The current date and time is <%= new java.util.Date() %>
  </body>
</html>

produced the following:

Hello World!
The current date and time is

I put the JSP file in the folder begjsp-ch01 which is a sub directory of webapps.

Hopefully this is a bit clearer.

Quote:
quote:Originally posted by jwenting
 You need to be a bit clearer here, what exactly is going wrong (or what do you expect to happen and what do you observe to happen)?
 
Old July 10th, 2003, 08:58 AM
Authorized User
 
Join Date: Jun 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jwenting Send a message via MSN to jwenting
Default

It looks like it's serving the file as plain HTML.

You probably saved the file as HTML instead of JSP (extension should be .jsp else Tomcat won't pass it to the JSP compiler/servlet engine but serve it as HTML in which case the <%= new java.util.Date() %> tag is simply passed on without parsing to your browser (which will then ignore it because it doesn't know what to make of it).

Also, while not strictly required it's good form to start a JSP with a tag <%@ page language="java" %>
 
Old July 10th, 2003, 09:51 AM
Registered User
 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found out the reason I was getting that the JSP code was not executing was opening the JSP using windows explorer and launching it with IE instead of keying in the URL http://localhost/begjsp-ch01/index.jsp. The reason I did it was when I keyed in the URL Tomcat gave me an error message saying the file was not available.

I got to to work by creating a subdirectory begjsp-ch01 from the examples directory and keying the appropriate URL. Does any new sub directory off of webapps need to be registered somewhere?

 
Old July 29th, 2004, 10:24 AM
Registered User
 
Join Date: Jul 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by evenpar
 I found out the reason I was getting that the JSP code was not executing was opening the JSP using windows explorer and launching it with IE instead of keying in the URL http://localhost/begjsp-ch01/index.jsp. The reason I did it was when I keyed in the URL Tomcat gave me an error message saying the file was not available.

I got to to work by creating a subdirectory begjsp-ch01 from the examples directory and keying the appropriate URL. Does any new sub directory off of webapps need to be registered somewhere?

I am having the same problem....
Are you saying that you literally copied the jsp-examples folder to the begjsp-ch01 folder, added the first JSP file in book - index.jsp - and it worked? Please tell me!!





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with tomcat any help? araknee Apache Tomcat 1 June 12th, 2008 07:04 AM
Facing problem with tomcat 5.5.9 bhojrajjoshi Apache Tomcat 14 September 26th, 2006 04:44 AM
configure tomcat to run both JDK 1.4.2 and 1.5.0 draggy Apache Tomcat 3 April 17th, 2006 04:04 AM
Apache, Axis and JDK for web service problem solomon_13000 Apache Tomcat 0 August 26th, 2005 08:16 AM
JDK 1.5 Setup Problem treehh JSP Basics 1 June 22nd, 2005 11:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.