[opencms-dev] simple bean usage

John Stanford White jswhite at ieee.org
Wed Aug 6 01:23:01 CEST 2003


Hello All,

My questions are simple:

How does one go about incorporating simple java classes into OpenCMS jsp pages.  Where does one place them?


I have recently  been exploring OPENCMS.  I run the standard Windows XP Pro. installation - Tomcat, MySql etc, OpenCMS 5.0.  I have developed all of the exercises from the JSP tutorial in a folder "jswstuff". I wanted to try using a very simple class file as a bean for some session data.   The class looks like the following:

public class MyUserData {    String username;
    String email;
    int age;
    public MyUserData() {}
    public void setUsername( String value )
    {
        username = value;
    }

    public void setEmail( String value )
    {
        email = value;
    }

    public void setAge( int value )
    {
        age = value;
    }

    public String getUsername() { return username; }

    public String getEmail() { return email; }

    public int getAge() { return age; }}The code that uses this is simple.  An html form is used to enter the name, email and age information which is passed to the following, called SaveUser.jsp

<%@ page import = "MyUserData" %>
<%@ page session="true" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<jsp:useBean id="myuser" class="MyUserData" scope="session"/>


<jsp:setProperty name="myuser" property="*"/> 


<cms:include property="template" element="head" />
<h3><A HREF="NextPage.jsp">Continue</A></h3>
<cms:include property="template" element="foot" />



My problem is I don't know where to place the class file for UserData. I tried the following:

1. Place the class file in the same folder "/jswstuff as a binary file.
2. Place a jar file containing the class in the \webapps\opencms\WEB-INF\lib, restart tomcat and hope for the best.

Well of course, none of this worked.  I got the following message when I requested the jsp that used the bean.  I reckon that what I am doing is contrary to the standard usage rules.  I have been playing with this all day.  I would be grateful for any suggestions.


javax.servlet.ServletException: Resource loader error in file '/jswstuff/SaveName.jsp'

Root cause:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] symbol  : class MyUserData 
    [javac] location: class org.apache.jsp.SaveName_jsp_jsp
    [javac]       MyUserData myuser = null;
    [javac





John Stanford White
917-576-6264 (cell)
212-794-1551 (home)
jswhite at ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20030806/b0ff3322/attachment.htm>


More information about the opencms-dev mailing list