[opencms-dev] simple bean usage

Joachim Arrasz info at arrasz.de
Wed Aug 6 07:37:01 CEST 2003


Hi,

You have to place your class file in a classes folder from a module where
you`ve planned to use your bean. But be careful you have to ensure that
you develop your Bean in right case for usage as bean for JSP`s.Then you have to decide where to fill your bean with informations.

Hope this helps

Kind Regards

Achim

-- 
Questions about OpenCMS?
--> www.synyx.de/board


> John Stanford White>
> 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






More information about the opencms-dev mailing list