aspose file tools
The moose likes JSP and the fly likes JSP Displays Source Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Displays Source" Watch "JSP Displays Source" New topic

JSP Displays Source

S Houde

Joined: Jul 01, 2003
Posts: 2
Hello all.
I am learning to use Beans with JSP, utilizing Tomcat 3.2.1. To make a long story short, I've modified server.xml to define a new webapp context, and believe I have my files and classes (WEB-INF\classes) in the correct directory sub-structure(s). The problem seems to be that when attempting to use a bean in a JSP, (regardless of scope) the browser returns a source listing of the JSP. I expect I have an ill-typed character in there somewhere, but if so, I haven't been able to locate it. Is there some general mistake I'm making that this problem is symptimatic of that more experienced deveopers might be able to spot (from experience, or course!). When I comment out the bean references int he JSP, the page seems to be otherwise parsed correctly. In attempting to debug this, I haven't seen any material that references this particular problem.
Well, thanks for any insights that can be cast my way.
- Steve
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 62832

When I comment out the bean references int he JSP, the page seems to be otherwise parsed correctly

Welcome to the Ranch!
It'd be helpful if you could post said offensive bean reference.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
S Houde

Joined: Jul 01, 2003
Posts: 2
Hey Bear,
Thnx for the welcome... its been a while, sorry for the delay here. I'm working thru a book 'JSP Weekend Crash Course', if that helps.
Anyway, below are the html page, JSP page and bean source. To reiterate, the problem is that when submitting the html, which should call the JSP page (includes bean), the result is that the browser just displays the text contents of the JSP page. I'm uising Tomcat 3.2.1, Java 1.3
Anyway here goes...
*** HTML: FruitOrder.html ***
<h2>Fruit Order Form</h2>
Price PER Pound: $5.95 <br>
<FORM action="confirm.jsp" method="post">
Number of Pounds: <input type="text" name="quantity"><br>
<input type="submit" value="Order Fruit">
*** confirm.jsp ***
<jsp:useBean id="orderedFruit" class="Fruit" />
<jsp:setProperty name="orderedFruit" property="fruitName" value="Mango" />
<jsp:setProperty name="orderedFruit" property="color" value="Orange" />
<jsp:setProperty name="orderedFruit" property="price" value="5.95" />
<jsp:setProperty name="orderedFruit" property="quantity" param="quantity" />
<h2>Your Fruit Order:</h2>
Fruit: <jsp:getProperty name="orderedFruit" property="fruitName" /><br>
Color: <jsp:getProperty name="orderedFruit" property="color" /><br>
Price: $<jsp:getProperty name="orderedFruit" property="price" /><br>
Quantity: <jsp:getProperty name="orderedFruit" param="quantity" /><br>
Total: $<%=orderedFruit.getPrice()*orderdedFruit.getQuantityInPounds() %>
<a href="FruitOrder.html">Return to order form to adjust a quantity</a>
*** ***
public class Fruit {

private String fruitName;
private int quantity;
private String color;
private boolean isCitrus;
private float price;
public String getFruitName() { return this.fruitName; }
public void setFruitName(String name) {
this.fruitName = name;
public int getQuantityInPounds() { return this.quantity; }
public void setQuantityInPounds(int quantity) {
this.quantity = quantity;
public String getColor() { return this.color; }
public void setColor(String color) {
this.color = color;
public float getPrice() { return this.price; }
public void setPrice(float price) {
this.price = price;
public boolean isCitrus() { return this.isCitrus; }
public void setCitrus(boolean isCitrus) {
this.isCitrus = isCitrus;
The bean compiles without exception. Apologies for the volume here, but thanks for taking the time to help, and encourage.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
3.2.1 is a very out of date version of Tomcat. Is there some reason you need to use it?

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12955
Is your JSP located in a directory that the engine will recognize as a "web application" - How about the compiled code for the bean?
It looks to me like you don't have the bean code in a package - this will cause lots of mysterious errors. Put the bean in a package and make sure the compiled class is in the right place under WEB-INF/classes
Be sure to specify the package in the useBean tag and import it in a page tag.
I agree. Here's the link:
subject: JSP Displays Source