Simple JSP example problems
Hello, I am new to JSP and I was wondering if I could get some help from some people that know what they are doing. I'm trying to run a simple JSP example that I got out of a book. But I've modified it a bit to just play around with it. But it doesn't want to run. I'm starting to think it's something wrong with the way I'm building/installing the stuff. I'm running IBM WebSphere 4 and JBuilder 8. I was just wondering if you could look at my code just to make sure I'm doing this right.
It's a pretty simple example. A JSP calls a class to get a message to print out.
Here's the code for the class: (HelloWorld.java)
package helloworld;
public class HelloWorld
private String message = "No message specified";
public String getMessage()
return(message);
public void setMessage(String message)
this.message = message;
=================================================================
Here's the code for the JSP: (HelloWorld.jsp)
<html>
<head>
<title>Using JavaBeans with JSP</title>
</head>
<body>
<jsp:useBean id="helloWorld" class = "helloworld.HelloWorld" />
<ol>
<li>Initial Value (JSP Expression):
<%= helloWorld.getMessage() %></li>
<li><jsp:setProperty name="helloWorld"
property="message"
value="Hello World" />
Value after setting property with setProperty:
<jsp:getProperty name="helloWorld"
property="message" /></li>
</ol>
</body>
</html>
I just wanted to be able to test out a JSP hitting a class file. Does someone have a better/easier way to do this? Or do you see anything wrong with my example? Thanks in advance.
The 1 thing missing in your example is the import directive for the helloworld.HelloWorld class.
Add the following line somewhere around the start of your jsp and things should be fine
<%@ page import="helloworld.HelloWorld" %>
Cheers
Similar Messages
-
Simple jsp example of using BI Bean in Myeclipse
hi
anyone can show me a simple jsp example of using BI Bean in Myeclipse
or how to import BI Bean into Myeclipse
I would so thankful for who can answer me.. please its urgent
thanksSorry, I was not very clear in my last message.
I need all my webservices to share the same bean during one user session.
Then, if a page calls 2 different web services, only 1 database connection is made instead of 2. And if the user opens other pages which call other webservices, they will use the connection kept into the session bean.
Anyway, I tried to do like it is said in your website but I can not build my project. I have an error : java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/C:/.../build/web/WEB-INF/lib/jaxb-impl.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. I do not understand because I have downloaded the jax-ws 2.1.1 api and no other libraries are imported in my project. :-(
I wonder if it is not related to netbeans... -
Simple Unmarshalling example problem
First of all let me say that I'm very new to this technology so please excuse my ignorance.
Now that being said. I'm trying to do a very simple JAXB unmarshaller example.
I have the following xml format:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Books>
<authFName>F. Scott</authFName>
<authLName>Fitzgerald</authLName>
<bookISBN>0-471-398233</bookISBN>
<bookName>The Great Gatsby</bookName>
<printDate>
<month>07</month>
<day>30</day>
<year>1978</year>
</printDate>
<publisher>Scribners</publisher>
</Books>Now I've got a books class
package com.example.book;
@javax.xml.bind.annotation.XmlRootElement(name="Books")
public class Books
private String bookName;
private String bookISBN;
private Date printDate;
private String publisher;
private String authFName;
private String authLName;
public Books() {}
public Books(String bookISBN, String bookName, int mth, int day, int year, String publisher, String aFName, String aLName)
this.setBookISBN(bookISBN);
this.setBookName(bookName);
printDate = new Date(mth,day,year);
this.setPublisher(publisher);
this.setAuthFName(aFName);
this.setAuthLName(aLName);
public String getAuthFName()
return authFName;
public void setAuthFName(String authFName)
this.authFName = authFName;
public String getAuthLName()
return authLName;
public void setAuthLName(String authLName)
this.authLName = authLName;
public void setBookName(String bookName)
this.bookName = bookName;
public String getBookName()
return bookName;
public void setBookISBN(String bookISBN)
this.bookISBN = bookISBN;
public String getBookISBN()
return bookISBN;
public void setPublisher(String publisher)
this.publisher = publisher;
public Date getPrintDate() {
return printDate;
public String getPublisher()
return publisher;
}and a Date class:
package com.example.book;
public class Date{
private int month;
private int day;
private int year;
public Date(){}
public Date(int m, int d, int y){
setDate(m,d,y);
private void setDate(int m, int d, int y){
setMonth(m);
setDay(d);
setYear(y);
private void setYear(int y) {
this.year = y;
private void setDay(int d) {
this.day = d;
private void setMonth(int m) {
this.month = m;
}And here's my test class:
package com.example.xml;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import com.example.book.Books;
public class UnmarshallingExample
public static void main(String[] args) throws JAXBException, FileNotFoundException
JAXBContext jc = null;
Unmarshaller u = null;
Books b1 = new Books();
jc = JAXBContext.newInstance(b1.getClass());
u = jc.createUnmarshaller();
b1 = (Books)u.unmarshal(new FileInputStream("UnMarshallingOutput.xml"));
System.out.println("FirstName: " + b1.getAuthFName());
System.out.println("LastName: " + b1.getAuthLName());
System.out.println("ISBN: " + b1.getBookISBN());
System.out.println("Book Name: " + b1.getBookName());
System.out.println("Print Date: " + b1.getPrintDate());
System.out.println("Publisher: " + b1.getPublisher());
}The result of this code is that my print date is null. I'm sure it has something to do with a missing annotation or something in the date class. But I haven't had any luck, does anybody have any suggestions?
Sorry for the length...
Cheers...Random attempt: I see no setPrintDate() on Books...
-
Problems with compilation of a Simple JSP
Hello!
This is a typical newbie problem with starting off on JDeveloper 3.0 (JDK 1.1.8) and Oracle 8i (8.1.1). When I create a simple JSP (The "Hello World" Jsp given in the File | New | Web Objects option) and try to run it - it gives me the following error :
java.io.IOException CreateProcess : cmd.exe /C start "" "C:\PROGRAM FILES\ORACLE\JDEVELOPER 3.0\myprojects\WebAppRunner.html" error = 0
Obviously the JSP does not run.
Any pointers about what might be wrong?
Regards
Mona<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Mona Marathe ([email protected]):
Hello!
This is a typical newbie problem with starting off on JDeveloper 3.0 (JDK 1.1.8) and Oracle 8i (8.1.1). When I create a simple JSP (The "Hello World" Jsp given in the File | New | Web Objects option) and try to run it - it gives me the following error :
java.io.IOException CreateProcess : cmd.exe /C start "" "C:\PROGRAM FILES\ORACLE\JDEVELOPER 3.0\myprojects\WebAppRunner.html" error = 0
Obviously the JSP does not run.
Any pointers about what might be wrong?
Regards
Mona<HR></BLOCKQUOTE>
The above error message is likely due
to JDeveloper looking for the NT command
interpreter named CMD.EXE .
I was able to run servlets with JDeveloper
and Windows 98 by copying COMMAND.COM to
C:\CMD.EXE, which was much easier to do
than putting a new OS on my machine.
Cheers,
David -
Problem getting JSP examples to work
Hi,
I just installed weblogic few days back. I'm trying to run the jsp examples.
I cannot get them work. I keep getting 404 object not found error when I try
an url like
http://localhost:7004/examplesWebApp/HellowWorld.jsp
. I followed the docs and run the scripts.
There is a HellowWorld.jsp file under
.\bea\wlserver\config\examples\applications\defaultWebApp.
Also I can run petstore fine or hellowworld works with default server.
But when I cannot get it tow work with exampleserver
Any pointer to debug is greatly appreciated.
There was a 'servlet mapping' error in hte xml parsing in the weblogic.xml file
which come with istallaiton for the example.
Anyone experienced that.
thanksif you put the HellowWorld.jsp under
\bea\wlserver\config\examples\applications\defaultWebApp. that means you
have it under default webapp, then your url should be:
http://localhost:7004/HellowWorld.jsp
The url pattern should be http://server:port/webappName/filename.jsp
thanks
"b gosh" <[email protected]> wrote in message
news:[email protected]..
>
Hi,
I just installed weblogic few days back. I'm trying to run the jspexamples.
I cannot get them work. I keep getting 404 object not found error when Itry
an url like
http://localhost:7004/examplesWebApp/HellowWorld.jsp
I followed the docs and run the scripts.
There is a HellowWorld.jsp file under
\bea\wlserver\config\examples\applications\defaultWebApp.
Also I can run petstore fine or hellowworld works with default server.
But when I cannot get it tow work with exampleserver
Any pointer to debug is greatly appreciated.
There was a 'servlet mapping' error in hte xml parsing in the weblogic.xmlfile
which come with istallaiton for the example.
Anyone experienced that.
thanks -
Simple struts example but it doesn't work
Hello everybody,
I'm new in struts technology and I wanted try a simple struts example, but it didn't work. Here are listings of code:
*** struts-config .xml (is located in WEB-INF/) :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
<struts-config>
<form-beans>
<form-bean name="registerForm" type="app.RegisterForm"/>
</form-beans>
<action-mappings>
<action path="/register"
type="app.RegisterAction"
name="registerForm">
<forward name="success" path="/success.html"/>
<forward name="failure" path="/failure.html"/>
</action>
</action-mappings>
</struts-config>
*** RegisterAction.java (located in WEB-INF/classes/app):
package app;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;
public class RegisterAction extends Action {
public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest req, HttpServletResponse res) {
// b Cast the form to the RegisterForm
RegisterForm rf = (RegisterForm) form;
String username = rf.getUsername();
String password1 = rf.getPassword1();
String password2 = rf.getPassword2();
// c Apply business logic
if (password1.equals(password2)) {
return mapping.findForward("success");
// E Return ActionForward for failure
return mapping.findForward("failure");
*** RegisterForm.java (located in WEB-INF/classes/app):
package app;
import org.apache.struts.action.*;
public class RegisterForm extends ActionForm {
protected String username;
protected String password1;
protected String password2;
public String getUsername() {return this.username;};
public String getPassword1() {return this.password1;};
public String getPassword2() {return this.password2;};
public void setUsername(String username) {this.username = username;};
public void setPassword1(String password) {this.password1 = password;};
public void setPassword2(String password) {this.password2 = password;};
*** faulire.html ( located webapps/NAME_APPLICATION/ )
<HTML>
<HEAD>
<TITLE>FAILURE</TITLE>
</HEAD>
<BODY>
Registration failed!
<P>try again?</P>
</BODY>
</HTML>
*** success.html ( located webapps/NAME_APPLICATION/ )
<HTML>
<HEAD>
<TITLE>SUCCESS</TITLE>
</HEAD>
<BODY>
Registration succeeded!
<P>try another?</P>
</BODY>
</HTML>
*** register.jsp ( located webapps/NAME_APPLICATION/ )
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:form action="register.do">
UserName:<html:text property="username"/><br>
enter password:<html:password property="password1"/><br>
re-enter password:<html:password property="password2"/><br>
<html:submit value="Register"/>
</html:form>
*** web.xml (located in WEB-INF/)
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<!-- Standard Action Servlet Configuration (with debugging) -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</web-app>
After start of NAME_APPLICATION it show register form (register.jsp) but when I fill out all information and submit those information it show empty window in internet browser and in url box is something like this:
http://localhost:8084/StrutsTest/register.do;jsessionid=2304C0A9820E7FCC23106C16564D51A8
where is a problem? Thank youEmploying a descendent of the Action class that does not implement the perform() method while using the Struts 1.0 libraries. Struts 1.1 Action child classes started using execute() rather than perform(), but is backwards compatible and supports the perform() method. However, if you write an Action-descended class for Struts 1.1 with an execute() method and try to run it in Struts 1.0, you will get this "Document contained no data" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer.
Also check this URL http://www.geocities.com/Colosseum/Field/7217/SW/struts/errors.html -
Re: [iPlanet-JATO] sp3 jsp compiler problem
Weiguo,
First, Matt is correct, the regular expression tool is perfect for general text
substitution situations, and as a completely independent tool its use is not
restricted to migration situations (or file types for that matter).
Second, I sympathize with the unfortunate trouble you are experiencing due to
Jasper's (perhaps more strict) compilation, but in what way did the iMT
automated translation contribute to these inconsistencies that you cited?
1. Changed the case of the tag attribute to be the same as what's
defined in tld.
example: changed OnClick to onClick
The iMT does not generate any OnClick or onClick clauses per se. In a
translation situation, the only way "OnClick" would have been introduced was if
it had been part of the pre-existing project's "extraHTML" (which was written
by the original customer and just passed through unchanged by the iMT) or if it
was added manually by the post-migration developer.
2. Removed attributes which are not defined in tld.
example: escape attribute only defined in three tags
but in some pages, it's used although it's not defined as an
attribute
of certain tags. The jasper compiler doesn't like it.Can you give soem examples? Is there a definite pattern? Again, this might be
similar to the OnClick situation described above?
3. In an end tag, there can't be any space.
example: </content > doesn't work. </content> works.
Again, the content tag would never have been generated by the iMT. There was no
equivalent in the NetDynamics world, so any content tags in your code must have
been introduced by your developers manually. Its a shame that jasper is so
particular, but the iMT could not help you out here even if we wanted to. The
constants that are used by the iMT are defined in
com.iplanet.moko.jsp.convert.JspConversionConstants. From what I can see, the
only situation of a closing tag with any space in it is
public static final String CLOSE_EMPTY_ELEMENT = " />";
But that should not cause the type of problem you are referring to.
Mike
----- Original Message -----
From: Matthew Stevens
Sent: Thursday, September 06, 2001 10:16 AM
Subject: RE: [iPlanet-JATO] sp3 jsp compiler problem
Weiguo,
Others will chime in for sure...I would highly recommend the Regex Tool from
the iMT 1.1.1 for tackling this type of problem. Mike, Todd and myself have
posted to the group (even recently) on directions and advantages of creating
your own RULES (rules file) in XML for arbitary batch processing of source.
matt
-----Original Message-----
From: weiguo.wang@b...
[mailto:<a href="/group/SunONE-JATO/post?protectID=125056020108194190033029175101192165174144234026000079108238073194105057099246073154180137239239223019162">weiguo.wang@b...</a>]
Sent: Thursday, September 06, 2001 12:25 PM
Subject: [iPlanet-JATO] sp3 jsp compiler problem
Matt/Mike/Todd,
We are trying to migrate to sp3 right now, but have had a lot of
issues with the new jasper compiler.
The following workaround has been employed to solve the issues:
1. Changed the case of the tag attribute to be the same as what's
defined in tld.
example: changed OnClick to onClick
2. Removed attributes which are not defined in tld.
example: escape attribute only defined in three tags
but in some pages, it's used although it's not defined as an
attribute
of certain tags. The jasper compiler doesn't like it.
3. In an end tag, there can't be any space.
example: </content > doesn't work. </content> works.
As I see it, we have two options to go about solving this problem:
1. Write a script which will iterate through all the jsp files and
call jspc on them. Fix the errors manually when jspc fails. Jspc will
flag the line number where an error occurs.
2. Write a utility which scans the jsp files and fix the errors when
they are encountered. We should define what's an error and how to
correct it. It's best if we combine this with solution 1 since we
might miss an error condition.
Actually, there might be another option, which is seeking help from
you guys since you have better understanding of JATO and iAS. Can you
do anything to help us?
We would be happy to hear your thoughts.
At last, I would like to suggest modifying the moko tool so that
these rules are enforced and the generated JSPs work with the new
compiler. This is for the benefit of any new migration projects.
Thanks a lot.
Weiguo
[email protected]
Choose from 1000s of job listings!
[email protected]
[Non-text portions of this message have been removed]Thanks a lot Matt and Mike for your prompt replies.
I agree completely that iMT doesn't introduce the inconsistencies.
About the three cases I mentioned, the third one happens only in
manually created JSPs. So it has nothing to do with iMT. The first
two are mainly due to the existing HTML code, as you rightly pointed
out.
The reason I made the suggestion is since we know that case 1 and 2
won't pass the japser compiler in sp3, we have to do something about
it. The best place to do this, in my mind, is iMT. Of course, there
might be some twists that make it impossible or difficult to do this
kind of case manipulation or attribute discard.
Weiguo
--- In iPlanet-JATO@y..., "Mike Frisino" <Michael.Frisino@S...> wrote:
Weiguo,
First, Matt is correct, the regular expression tool is perfect for general text substitution situations, and as a completely independent
tool its use is not restricted to migration situations (or file types
for that matter).
>
Second, I sympathize with the unfortunate trouble you are experiencing due to Jasper's (perhaps more strict) compilation, but
in what way did the iMT automated translation contribute to these
inconsistencies that you cited?
>
1. Changed the case of the tag attribute to be the same as what's
defined in tld.
example: changed OnClick to onClick
The iMT does not generate any OnClick or onClick clauses per se. In a translation situation, the only way "OnClick" would have been
introduced was if it had been part of the pre-existing
project's "extraHTML" (which was written by the original customer and
just passed through unchanged by the iMT) or if it was added manually
by the post-migration developer.
>
2. Removed attributes which are not defined in tld.
example: escape attribute only defined in three tags
but in some pages, it's used although it's not defined as an
attribute
of certain tags. The jasper compiler doesn't like it.Can you give soem examples? Is there a definite pattern? Again, this might be similar to the OnClick situation described above?
>
>
3. In an end tag, there can't be any space.
example: </content > doesn't work. </content> works.
Again, the content tag would never have been generated by the iMT. There was no equivalent in the NetDynamics world, so any content tags
in your code must have been introduced by your developers manually.
Its a shame that jasper is so particular, but the iMT could not help
you out here even if we wanted to. The constants that are used by the
iMT are defined in
com.iplanet.moko.jsp.convert.JspConversionConstants. From what I can
see, the only situation of a closing tag with any space in it is
public static final String CLOSE_EMPTY_ELEMENT = " />";
But that should not cause the type of problem you are referring to.
Mike
----- Original Message -----
From: Matthew Stevens
Sent: Thursday, September 06, 2001 10:16 AM
Subject: RE: [iPlanet-JATO] sp3 jsp compiler problem
Weiguo,
Others will chime in for sure...I would highly recommend the Regex Tool from
the iMT 1.1.1 for tackling this type of problem. Mike, Todd and myself have
posted to the group (even recently) on directions and advantages of creating
your own RULES (rules file) in XML for arbitary batch processing of source.
>
matt
-----Original Message-----
From: weiguo.wang@b...
[mailto:<a href="/group/SunONE-JATO/post?protectID=125056020108194190033029175101192165174048139046">weiguo.wang@b...</a>]
Sent: Thursday, September 06, 2001 12:25 PM
Subject: [iPlanet-JATO] sp3 jsp compiler problem
Matt/Mike/Todd,
We are trying to migrate to sp3 right now, but have had a lot of
issues with the new jasper compiler.
The following workaround has been employed to solve the issues:
1. Changed the case of the tag attribute to be the same as
what's
defined in tld.
example: changed OnClick to onClick
2. Removed attributes which are not defined in tld.
example: escape attribute only defined in three tags
but in some pages, it's used although it's not defined as an
attribute
of certain tags. The jasper compiler doesn't like it.
3. In an end tag, there can't be any space.
example: </content > doesn't work. </content> works.
As I see it, we have two options to go about solving this problem:
>>
1. Write a script which will iterate through all the jsp files and
call jspc on them. Fix the errors manually when jspc fails. Jspc will
flag the line number where an error occurs.
2. Write a utility which scans the jsp files and fix the errors when
they are encountered. We should define what's an error and how to
correct it. It's best if we combine this with solution 1 since we
might miss an error condition.
Actually, there might be another option, which is seeking help from
you guys since you have better understanding of JATO and iAS. Can you
do anything to help us?
We would be happy to hear your thoughts.
At last, I would like to suggest modifying the moko tool so that
these rules are enforced and the generated JSPs work with the new
compiler. This is for the benefit of any new migration projects.
Thanks a lot.
Weiguo
[email protected]
Choose from 1000s of job listings!
[email protected]
Service.
>
>
>
[Non-text portions of this message have been removed] -
How do I expand my simple JSP page to implement Connection Pooling?
Hi everyone,
I have a small SQL database which contains information about Students and a StudenBean which contains their attributes and appropriate get/set methods (which I haven't needed to use yet).
I want to write a simple JSP page which displays all the students details in one big table. I can do this using the basic prototyping method of adding the dataSource and driver details to the deployment descriptor (web.xml - I'm using the latest version of Tomcat by the way) and then accessing the database using JSP standard SQL actions.
Here's a snipet of what I've done (just an example, the final code works):
<sql:query var="temp"
sql="SELECT * FROM Employee ORDER BY UserName"
/>
<c:forEach items="${temp.rows}" var="row">
<td><c:out value ="${row.UserName}"/></td>
<td><c:out value ="${row.FirstName}"/></td>
<td><c:out value ="${row.LastName}"/></td>
Now I want to upgrade! I want to access the dataSource using Connection Pooling and it's causing me a lot of trouble. I already have the required working classes/data such as ConnectionPool.java, ResourceManagerListener.java, the MySQL driver etc.
However, I don't know what the best way to setup the connection for my purposes would be and where I should do it.
Do I need to write a servlet or tag handler/custom action to establish the connection and access my bean through it? I would like to keep a similar sort of business logic as I already have developed i.e. be able to use actions in my JSP page to cycle through the database and print out each detail from the row.
Rather confused and muddled. Thanks for any input!Good idea.
Set up a JNDI data source for your app, according to these docs:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
You'll have to put the right information into your web.xml and a context.xml. Once you've done that, your JSTL JSPs will simply use the connection resource automagically.
MOD -
My simple jsp doesn't work: hhhelp
hello i'm new to java.
I'm testing a simple jsp with a javabean: Fruit.class
When i test it , it seems there is a problem of package (but i really need help on this)...
Here's the error i get:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\apache\jsp\confirm_jsp.java:44: cannot resolve symbol
symbol : class Fruit
location: class org.apache.jsp.confirm_jsp
Fruit commandeFruit = null;
^
here's the full error report
Etat HTTP 500 -
type Rapport d'exception
message
description Le serveur a rencontr� une erreur interne () qui l'a emp�ch� de satisfaire la requ�te.
exception
org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP
Une erreur s'est produite � la ligne: 2 dans le fichier jsp: /confirm.jsp
Erreur de servlet g�n�r�e:
[javac] Compiling 1 source file
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\apache\jsp\confirm_jsp.java:44: cannot resolve symbol
symbol : class Fruit
location: class org.apache.jsp.confirm_jsp
Fruit commandeFruit = null;
^
Une erreur s'est produite � la ligne: 2 dans le fichier jsp: /confirm.jsp
Erreur de servlet g�n�r�e:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\apache\jsp\confirm_jsp.java:46: cannot resolve symbol
symbol : class Fruit
location: class org.apache.jsp.confirm_jsp
commandeFruit = (Fruit) _jspx_page_context.getAttribute("commandeFruit", PageContext.PAGE_SCOPE);
^
Une erreur s'est produite � la ligne: 2 dans le fichier jsp: /confirm.jsp
Erreur de servlet g�n�r�e:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\apache\jsp\confirm_jsp.java:48: cannot resolve symbol
symbol : class Fruit
location: class org.apache.jsp.confirm_jsp
commandeFruit = new Fruit();
^
Une erreur s'est produite � la ligne: 16 dans le fichier jsp: /confirm.jsp
Erreur de servlet g�n�r�e:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\apache\jsp\confirm_jsp.java:71: cannot resolve symbol
symbol : class Fruit
location: class org.apache.jsp.confirm_jsp
out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((Fruit)_jspx_page_context.findAttribute("commandeFruit")).getNomFruit())));
^
Une erreur s'est produite � la ligne: 17 dans le fichier jsp: /confirm.jsp
Erreur de servlet g�n�r�e:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\apache\jsp\confirm_jsp.java:74: cannot resolve symbol
symbol : class Fruit
location: class org.apache.jsp.confirm_jsp
out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((Fruit)_jspx_page_context.findAttribute("commandeFruit")).getCouleur())));
^
Une erreur s'est produite � la ligne: 18 dans le fichier jsp: /confirm.jsp
Erreur de servlet g�n�r�e:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\apache\jsp\confirm_jsp.java:77: cannot resolve symbol
symbol : class Fruit
location: class org.apache.jsp.confirm_jsp
out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((Fruit)_jspx_page_context.findAttribute("commandeFruit")).getPrix())));
^
Une erreur s'est produite � la ligne: 19 dans le fichier jsp: /confirm.jsp
Erreur de servlet g�n�r�e:
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\apache\jsp\confirm_jsp.java:80: cannot resolve symbol
symbol : class Fruit
location: class org.apache.jsp.confirm_jsp
out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((Fruit)_jspx_page_context.findAttribute("commandeFruit")).getPoids())));
^
7 errors
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note La trace compl�te de la cause m�re de cette erreur est disponible dans les fichiers journaux de Tomcat.
--------------------------------------------------------------------------------hello i tried what you told me but it steel seems i've
got 2 errors
here's the error
exception
org.apache.jasper.JasperException: Impossible de
compiler la classe pour la JSP
Une erreur s'est produite � la ligne: 5 dans le
fichier jsp: /confirm.jsp
Erreur de servlet g�n�r�e:
[javac] Compiling 1 source file
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\
pache\jsp\confirm_jsp.java:6: <identifier> expected
import full.package.name.Fruit;
^
C:\jakarta-tomcat-5.0.19\work\Catalina\localhost\_\org\
pache\jsp\confirm_jsp.java:47: cannot resolve symbol
symbol : class Fruit
location: class org.apache.jsp.confirm_jsp
Fruit commandeFruit = null;
^--------------------------------------
here's my jsp:
<%-- confirm.jsp --%>
<%@ page import="full.package.name.Fruit" %>
<jsp:useBean id="commandeFruit" class="Fruit" />
<jsp:setProperty name="commandeFruit"
property="nomFruit" value="Mangue" />
<jsp:setProperty name="commandeFruit"
property="couleur" value="Orange" />
<jsp:setProperty name="commandeFruit" property="prix"
value="5.95" />
<jsp:setProperty name="commandeFruit" property="poids"
param="saisie_poids" />
<HTML>
<body>
<h1>Votre commande de fruit (confirm.jsp)</h1>
<br>
Fruit : <jsp:getProperty name="commandeFruit"
property="nomFruit"/><br>
Couleur : <jsp:getProperty name="commandeFruit"
property="couleur" /><br>
Prix au kg : <jsp:getProperty name="commandeFruit"
property="prix" /> Euros<br>
Quantit� : <jsp:getProperty name="commandeFruit"
property="poids" /><br>
Total
:�<%=commandeFruit.getPrix()*commandeFruit.getPoid
() %> Euros<p></p>
Revenir � la commande pour
la modifier
</body>
</html>
First error is becoz you are using word package which is a standard identifier. So you have to change ur folder name to smething else other than package.
Second error is becoz of the first error. If the forst error is fixed second error will not occur.
Thanks
KM -
Jsp compilation problem in IAS ?.
None of the JSP's present in a directory with a name "default" gets compiled . I get the javac exception given below.
Tried it out with Fortune sample application by creating a drectory with a name "default" .Even a simple jsp with a "hello" string also fails . Is "default" some kind of key word in IAS .
javac error: /usr/local/iplanet/ias6.new/ias/APPS/fortune/fortune/WEB-INF/compiled_jsp/jsp/APPS/fortune/default/test.java:1: Identifier expected. package jsp.APPS.fortune.default; Superclass HttpJspBase of class test not found. public class test extends HttpJspBase { ^ 2 errorsHi,
I can give you a quick answer that this could be an issue. However, I would like to experiment and prove by testing across various platform and different service packs. Please let me know more details, especially on the default directory, like where the directory resides, how you have packaged the application and what is the name of the application etc. This will help me to replicate the problem and conclude at a solution.
Thanks & Regards
Ganesh .R
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers/support -
JWSDP 2.0 JAX-RPC example problem Fast Infoset
Hi,
I installed JWSDP 2.0 and and Tomcat 5.0 for JWSDP. The server runs fine and the example HelloWorld is accessible (I can see the WSDL file in my browser: http://localhost:8080/jaxrpc-HelloWorld/hello?WSDL).
The Problem is that I can not run the client: I tried "ant run-client". The error occurs while trying to create a stub in the file "HelloClient.java" with the following line of code:
stub = (HelloIF_Stub) (helloWorldService.getHelloIFPort());
This is the error I get:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/jvnet/fastinfoset/FastInfosetSource
[java] at hello.HelloWorldService_Impl.getHelloIFPort(HelloWorldService_Impl.java:59)
[java] at hello.HelloClient.setUp(HelloClient.java:68)
[java] at hello.HelloClient.main(HelloClient.java:45)
[java] Java Result: 1
I am not sure about the structure of the application, so I don't know where to look for the "FastInfosetSurce" file.
Thanks for any help.
Best regards.Hi,
I reselved the problem by just copying the FastInfoset to the jaxrpc\lib directory (I am sure this should work in a different way).
Well, the next problem I am getting is that the "XMLStreamWriter" class cannot be found. This class is contained in jsr173_api.jar.
I guess my main question is the following:
Which projects are necessary to get this simple helloWorld example to work?
I did set the JWSDP_HOME varible. Is there another setting I have to make to have all necessary jar-files available and to be able to run the samples?
Could anybody point me to a tutorial that does not only show a few lines of code (as the HelloWorld sample in the JWSDP-Tutorial) but that would instead lead me through a step-by-step sample application that I write by myself and actually runs at the end? The example in the JWSDP-Tutorial uses all kinds of existing config files which are not explained.
Thanks for your help. -
Deployment of simple JSP to Oracle Servlet Engine
Hi
Anyone there tried to deploy a simple JSP running against OSE.
Please advice where can I get more information for this.
ThanksYes I have tried it with simple examples like data access and calling EJB. In-session EJB calls do not work but if your JSP is deployed in another Oracle JVM like 9iAS then EJB calls work.
There are two manuals you can refer:
JSP Developers guide at http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/java.817/a83720/toc.htm
AND
Java Tools reference guide at http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/java.817/a83727/toc.htm
null -
JSP Compile problem with WLS 5.1 sp9
Hi All,
The attached, simple JSP file uses a custom tag, and some JavaScript. When
this is compiled into Java, the Java that is created is Bad. It seems as if
WLS is having problems properly escaping single-quotes and double-quotes.
Also attached, is the generated Java file. Note around line 82, and compare
that to around line 15 of the JSP.
Does anyone have an idea what can be done to fix this? This JSP compiles
fine under Tomcat 3.2.
Thanx!
Will Hartung
([email protected])
[test.jsp]
[_test.java]
Hi All,
The attached, simple JSP file uses a custom tag, and some JavaScript. When
this is compiled into Java, the Java that is created is Bad. It seems as if
WLS is having problems properly escaping single-quotes and double-quotes.
Also attached, is the generated Java file. Note around line 82, and compare
that to around line 15 of the JSP.
Does anyone have an idea what can be done to fix this? This JSP compiles
fine under Tomcat 3.2.
Thanx!
Will Hartung
([email protected])
[test.jsp]
[_test.java]
-
Hi,
Could someone please help on the above mentioned?
I'm using JDeveloper 3.2.3 for my program development under Chinese windows platform. I have created a simple JSP page, which contains few static Chinese words and I have included the line
<%@ page contentType="text/html;charset=UTF-8"%>
at the top of the page. When I tried to compile it using encoding "UTF8" (under compiler option), the compiler gave me this error:
C:\Program Files\Oracle\JDeveloper 3.2.3\myhtml\Chinese_html\ChineseList.jsp
Error: (0) sun.io.MalformedInputException.
Btw, when I have removed the line <%@ page contentType="text/html;charset=UTF-8"%> from the page and compile, I've got this error:
C:\Program Files\Oracle\JDeveloper 3.2.3\myhtml\Chinese_html\ChineseList.jsp
Warning: (0) ISO-8859-1 character set may not match project compiler setting.
C:\Program Files\Oracle\JDeveloper 3.2.3\myhtml\Chinese_html\ChineseList.java
Error: (0) malformed input character in C:\Program Files\Oracle\JDeveloper 3.2.3\myhtml\Chinese_html\ChineseList.java.
I do appreciate your help on this. Thank you.Here's some info one of the JSP Developers sent me:
1. HELP.....!!!!! Chinese jsp compilation problem.....
The customer is trying to parse a document generated by
Windows's notepad. When saved in UTF-8, the byte
order mark is saved too. We have a know bug that
JSP parser doesn't recognize Byte Order Mark. The
bug is : 1915285.
2. CHINESE CHARACTER ON JSP
. SQLPLUS depends on NLS_LANG setting. If you
check the windows registry, the default of NLS_LANG
depends on the OS. The user environment is Traditional
Chinese, so does NLS_LANG. If we set NLS_LANG
to .UTF8, SQLPLUS dumps the data in UTF8, however,
the command prompt will have problem displaying them.
. For JSP, as mentioned in a previous mail:
<%@ page contentType="text/html;charset=UTF-8" %> for all languages
<%@ page contentType="text/html;charset=GB2312" %> for simplified Chinese
<%@ page contentType="text/html;charset=Big5" %> for traditional Chinese
. When you enter Chinese characters on a browser,
the data is automatically converted to page encoding
(UTF-8 in your case) before sent back to the server.
But your receiving servlet/JSP needs to have request
encoding set correctly.
I'm not sure about the JDeveloper environment,
but here is a simple JSP you may try to verify your
OC4J environment:
a. To set up the schema:
connect scott/tiger
create table tab01(col varchar2(100));
b. Edit the connect string in nls.jsp
c. Run the nls.jsp in oc4j instance.
<!-- nls.jsp -->
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="oracle.jdbc.*,java.sql.*,java.io.*"%>
<HTML>
<HEAD>
<TITLE>Hello</TITLE></HEAD>
<BODY>
<%
request.setCharacterEncoding("UTF-8");
String sampledata="\u7D20";
String paramValue = request.getParameter("myparam");
String connStr = "jdbc:oracle:thin:@dlsun478:5521:j2ee01";
String user = "scott";
String passwd = "tiger";
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection(connStr, user, passwd);
if (paramValue == null || paramValue.length() == 0) { %>
<FORM METHOD="GET">
Please input your name: <INPUT TYPE="TEXT" NAME="myparam"
value="<%=sampledata%>" size=20>
<BR>
<INPUT TYPE="SUBMIT" value="Insert Data">
</FORM>
<%
selectData(conn, out);
else
%>
<H1> Insert Data: <%= paramValue %> </H1>
<br/>
<%
insertData(conn, paramValue);
%>
<a href="nls.jsp">back</a>
<%
%>
</BODY>
</HTML>
<%!
public void insertData(Connection aConn, String myval)
try {
PreparedStatement stmt = aConn.prepareStatement("insert into tab01
values(?)");
stmt.setString(1, myval);
stmt.executeUpdate();
aConn.close();
catch (SQLException e) {
e.printStackTrace();
public void selectData (Connection aConn, JspWriter out)
try {
Statement stmt = aConn.createStatement( );
ResultSet r = stmt.executeQuery("SELECT col FROM tab01");
out.println("<H1>List of Data:</H1>");
while (r.next()) {
out.println(r.getString(1)+"<br/>");
aConn.close();
catch (SQLException e) {
e.printStackTrace();
catch (IOException e) {
e.printStackTrace();
%> -
Simple DataSocket example hangs the DataSocket server
Hi,
I am having problems with the Simple DataSocket example. As soon as I try to connect to the DataSocket server on the local machine using dstp the server crashes. The error signature is:
AppName: cwdss.exe AppVer: 4.2.3.1 ModName: mfc42.dll
ModVer: 6.2.4131.0 Offset: 0001bc9b
By restarting the server I am sometimes able to connect but most of the time this only results in a repeated crash. Furthermore when I try to close either the reader or the writer after such a crash I get the error message “the RPC-server is not available”. The only way to close the program is to use the task manager. I am using Measurement Studio 7.1 and Visual Studio 2003 version 7.1.3088 and I have successfully used DataSocket to communicate with an OPC server on the local machine. I would appreciate any suggestions on how to solve the problems since I would like use dstp in my own applications.
AdamAs I wrote in the original post, it is the simple datasocket example that I am having trouble with. I have managed to get the reader and writer to talk to each other by restarting the datasocket server repeatedly, but since the datasocket server crashes most of the times when I try to connect to it (i.e. I press either manual or auto update connect) this is rather tedious work. I think that the files were replaced correctly; at least the file cwdss.exe reappeared. The version of cwdss.exe is 4.2.3.1. Which other files should I check? The version of nids.dll is the same, i.e. 4.2.3.1.
Adam
Maybe you are looking for
-
Loop at internal Table inside Script
Hi I am filling a table in a subroutine in a program and calling it through 'Perform' from my Script,now the main issue is , How to display the table in my script ? I want to loop through an internal table & display its content on my
-
Hi, I am copying the standard MEDRUCK form to ZMEDRUCK. I believe standard MEDRUK form will be used for new purchase orders as well changed purchased orders and for the changed purchase orders it will print only changed lines and header. In the
-
I'm using Pages '09, Version 4.1 I've used tables to make a crossword grid. One with letters supplies the solutiuon. The other can be numbered in the top left hand corner. I've sussed all that. Now I need to keep the grid in place and add text boxes
-
E-mails from "Yesterday" showing up as "Today"
This is weird. Not sure if this is a recent issue or I just noticed it. In my list of e-mails (All inboxes and the individual ones), the e-mails from yesterday have a date that says "Today". The e-mails from today correctly list the time they were re
-
someone help me fix my phone i have had ios7 since it came out and it has randomly come up with 'Activation Required' never had any problems with the iphone so how do i fix this ?