Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

jsp not running...

I have CarBean.jsp at:
...Tomcat 5.0\webapps\begjsp-ch04\CarBean.jsp

Its content is:


<html>
      <head>
            <title>Using a JavaBean</title>
      </head>
      <body>
            <h2>Using a JavaBean</h2>
            <% myCar = new CarBean();%>
            I own a <%=myCar.getMake()%>
            <%myCar.setMake("Ferrari");%>
            Now I own a <%=myCar.getMake();%>
      </body>
</html>

---------------------
the associated CarBean class is compiled and put in the following folder:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\begjsp-ch04\WEB-INF\classes

Its content is:

public class CarBean {

      public CarBean() {
      }

      private String make = "Ford";

      public String getMake() {

            return make;
      }

      public void setMake(String make) {


            this.make = make;

      }

}

----------------------------
I am using the following url to open this page:

http://localhost:8080/begjsp-ch04/CarBean.jsp

It fails. What is wrong with this? Can you please debug?

Thank you.
Avatar of for_yan
for_yan
Flag of United States of America image

you need the import statemne in the beginning of jsp
try to put this at the top:
<%@ page language="java" import="CarBean" %>
Once again go to examples application in tthe tomcat webapps folder and the go to jsp there - most of them use classes - chek out how they are imported, like in theis example for calculator for instance:

<HTML>
<!--  
  Copyright (c) 1999 The Apache Software Foundation.  All rights 
  reserved.
-->
<HEAD><TITLE> 
	Calendar: A JSP APPLICATION
</TITLE></HEAD>


<BODY BGCOLOR="white">

<%@ page language="java" import="cal.*" %>
<jsp:useBean id="table" scope="session" class="cal.TableBean" />

<%
	table.processRequest(request);
	if (table.getProcessError() == false) {
%>

<!-- html table goes here -->
<CENTER>
<TABLE WIDTH=60% BGCOLOR=yellow CELLPADDING=15>
<TR>
<TD ALIGN=CENTER> <A HREF=cal1.jsp?date=prev> prev </A>
<TD ALIGN=CENTER> Calendar:<%= table.getDate() %></TD>
<TD ALIGN=CENTER> <A HREF=cal1.jsp?date=next> next </A>
</TR>
</TABLE>

<!-- the main table -->
<TABLE WIDTH=60% BGCOLOR=lightblue BORDER=1 CELLPADDING=10>
<TR>
<TH> Time </TH>
<TH> Appointment </TH>
</TR>
<FORM METHOD=POST ACTION=cal1.jsp>
<%
	for(int i=0; i<table.getEntries().getRows(); i++) {
	   cal.Entry entr = table.getEntries().getEntry(i);	
%>
	<TR>
	<TD> 
	<A HREF=cal2.jsp?time=<%= entr.getHour() %>>
		<%= entr.getHour() %> </A>
	</TD>
	<TD BGCOLOR=<%= entr.getColor() %>>
	<%= entr.getDescription() %>
	</TD> 
	</TR>
<%
	}
%>
</FORM>
</TABLE>
<BR>

<!-- footer -->
<TABLE WIDTH=60% BGCOLOR=yellow CELLPADDING=15>
<TR>
<TD ALIGN=CENTER>  <%= table.getName() %> : 
		     <%= table.getEmail() %> </TD>
</TR>
</TABLE>
</CENTER>

<%
	} else {
%>
<font size=5>
	You must enter your name and email address correctly.
</font>
<%
	}
%>


</BODY>
</HTML>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rrz
eghtebas,   Did that solution really work for you ?
Avatar of Mike Eghtebas

ASKER

rrz@871311,

The input from for_yan was accurate. I had additional issues with my environment setup.

Thank you for the follow up

Mike