Solved

jsp not running...

Posted on 2012-03-27
7
292 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: 37774421
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37774438
try to put this at the top:
<%@ page language="java" import="CarBean" %>
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

734 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