Solved

jsp not running...

Posted on 2012-03-27
7
293 Views
Last Modified: 2012-06-27
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.
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
7 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 37774418
you need the import statemne in the beginning of jsp
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37774438
try to put this at the top:
<%@ page language="java" import="CarBean" %>
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 47

Expert Comment

by:for_yan
ID: 37774473
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

0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 37774546
Put this myCar.jsp (see below)  into webapps/examples

Put your CarBean.class into examples/WEB-INF/classes

and then
http://localhost:8080/examples/myCar.jsp

should work

Maybe you would need to reastrt Tomcat


<html>
      <head>
            <title>Using a JavaBean</title>
      </head>
      <body>
      <%@ page language="java" import="*" %>
      <jsp:useBean id="car" scope="session" class="CarBean" />


            <h2>Using a JavaBean</h2>
           
            I own a <%=car.getMake()%>
            <%car.setMake("Ferrari");%>
            Now I own a <%=car.getMake()%>
      </body>
</html>

Open in new window



output in the browser:

Using a JavaBean
I own a Ferrari Now I own a Ferrari 

Open in new window

0
 
LVL 27

Expert Comment

by:rrz
ID: 37777325
eghtebas,   Did that solution really work for you ?
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 37780410
rrz@871311,

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

Thank you for the follow up

Mike
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question