Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JSP problem with tomcat 5.0.28

Status
Not open for further replies.

pegazaus

Instructor
Aug 16, 2005
22
SE
Hi

I 'm beginner with tomcat and I have a problem with JSP files.
I have tomcat5.0.28 (preconfigured) installed on WINXP OS.
I'm working in ROOT directory (C:\Program\Apache Software Foundation\Tomcat 5.0\webapps\ROOT), this is where all my jsp files are, and my java class-file are in a package called "elie_paket" in "C:\Program\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes\elie_paket "

The problem is that I have a servlet that forwards(request, response) from a jsp file to another.
1- from betyg.jsp-
Code:
<form action="[URL unfurl="true"]http://localhost:8080/servlet/elie_paket.BetygServlet"[/URL] method="GET">
. It's call the servlet when submitting

2- if everything is ok the theservlet "BetygServet" forwards to "saveit.jsp":
Code:
"RequestDispatcher rd = request.getRequestDispatcher("saveit.jsp");
	    			 request.setAttribute("elev",elev);
	    			 rd.forward(request,response);"
3- savit.jsp is supposed to receive the request.

The problem is that I receive the follwing msg after submitting from "betyg.jsp":

HTTP Status 404 - /servlet/saveit.jsp
type Status report
message /servlet/saveit.jsp
description The requested resource (/servlet/saveit.jsp) is not available.


"saveit.jsp" looks like that:
Code:
 <%@page contentType="text/html"%>
<jsp:useBean id="elev" class="StudentBean" scope="request"/>
<jsp:getPropety name="elev" property="*"/>
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html">
    <title>Inlupp9</title>
  </head>
  
<body>
<h3 style="font-family:verdana; color:red;background-color:lightblue">Studen</h3>
<pre style="font-family:verdana; color:red;background-color:lightblue">
   Namn       : <%= elev.getName()%>
   Tenta Poäng: <%= elev.getPoang()%>
   Tenta Betyg: <%= elev.getBetyg()%>
</pre>

<%@include file ="betyg.jsp"%>
</body>
</html>
and is in "C:\Program\Apache Software Foundation\Tomcat 5.0\webapps\ROOT"

I read about doing something in "C:\Program\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\web.xml" . But I don't have any idea about what to do.

I appreciate all help.
Thks in advanced
 
Change :

RequestDispatcher rd = request.getRequestDispatcher("saveit.jsp");

to :

RequestDispatcher rd = request.getRequestDispatcher("/saveit.jsp");

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Thanks nor the problem is solved but an other problem came up.
I have the floowing bean, StudentBean:
Code:
package elie_paket;

  public class StudentBean{
	
    String Namn;
	float tentapng;
	String tentabetyg;
	
	public StudentBean(){
	}
	
	public String getNamn(){
		return Namn;
	}
	
	public float getPoang(){
		return tentapng;
	}
	
	public String getBetyg(){
		return tentabetyg;
	}
	public void setNamn(String Namn){
		this.Namn= Namn;
	}
	
	public void setPoang(float png){
		tentapng=png;
	}
	
	public void setBetyg(String betyg){
		tentabetyg = betyg;
	}
}

and the following JSP, saveit.jsp
Code:
<%@page contentType="text/html"%>

<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html">
    <title>Inlupp9</title>
  </head>
  
<body>
<h3 style="font-family:verdana; color:red;background-color:lightblue">Föjande student Info sparas:</h3>
<pre style="font-family:verdana; color:red;background-color:lightblue">
<jsp:useBean id="elev" class="elie_paket.StudentBean" scope="request">
 Hello
</jsp:useBean>
   Namn       : <jsp:getProperty name="elev" property="Namn"/>
   Tenta Poäng: <!--jsp:getProperty name="elev" property="tentapng"/-->
   Tenta Betyg: <!--jsp:getProperty name="elev" property="tentabetyg"/-->
</pre>

<%@include file ="betyg.jsp"%>
</body>
</html>

On execution I get the following error
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Cannot find any information on property '<%elev.getNamn()%>' in a bean of type 'elie_paket.StudentBean'
org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:837)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1015)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1062)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3272)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
elie_paket.BetygServlet.doGet(BetygServlet.java:76)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:419)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
-----------------------------------------------------------
Apache Tomcat/5.0.28


I'm really confused.
Great thks for all Help.
 
You have not written the bean correctly - you should change "Namn" to "namn" in the bean.

In the JSP, you should also change "Namn" to "namn", eg :

Code:
Namn       : <jsp:getProperty name="elev" property="namn"/>


--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top