You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chuck Amadi <ch...@breconbeacons.org> on 2001/07/02 15:04:50 UTC

Re: newbie question (again)

Hi , if possible could you post your syntax regarding your
<html:form></html:form>. As i have design and created a user form for a on-line
comments planning application form in regular html/JavaScript. Nevertheless i
would'nt mind cropping it within a bean that of cause can be reused and give a
better impresssion with my boss.

Cheers Chuck

Tiffany Dodge wrote:

> Hello,
>
> I added a "<html"form" command to my jsp and created a Form and Action
> object, but I got the same error.  :(  Here's everything again.  I would
> very much appreciate any suggestions/comments as to why things aren't
> working.  (FYI, I am using WebLogic 5.1 with SP8.)
>
> Thanks in advance,
> Tiff
>
> ERROR
> =====
> Before the title.
> Fri Jun 29 13:01:30 PDT 2001:<E> <WebAppServletContext-bumbletrak> Root
> cause of
>  ServletException
> javax.servlet.ServletException: runtime failure in custom tag 'message'
>         at
> jsp_servlet._createnewperson2._jspService(_createnewperson2.java:108)
>
>         at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
> pl.java:106)
>         at
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
> pl.java:124)
>         at
> weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
> textImpl.java:907)
>         at
> weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
> textImpl.java:851)
>         at
> weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
> ContextManager.java:252)
>         at
> weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
> a:364)
>         at
> weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:252)
>
>         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
>
> CreateNewPerson2.jsp
> ====================
> <%@ page language="java"%>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
>
> <html:html locale="true">
>   <head>
>     <% System.out.println("Before the title."); %>
>     <title><bean:message key="CreateNewPerson2.title"/></title>
>     <% System.out.println("After the title."); %>
>     <html:base/>
>   </head>
>   <body bgcolor="white">
>     <html:errors/>
>     <html:form action="/savePerson">
>       <table border="0" width="100%">
>         <tr>
>           <th align="right">
>             <bean:message key="prompt.firstName"/>
>           </th>
>           <td align="left">
>             <html:text property="firstName" size="25"/>
>           </td>
>         </tr>
>         <tr>
>           <th align="right">
>             <bean:message key="prompt.middleName"/>
>           </th>
>           <td align="left">
>             <html:text property="middleName" size="10"/>
>           </td>
>         </tr>
>         <tr>
>           <th align="right">
>             <bean:message key="prompt.lastName"/>
>           </th>
>           <td align="left">
>             <html:text property="lastName" size="25"/>
>           </td>
>         </tr>
>         <tr>
>           <th align="right">
>             <bean:message key="prompt.gender"/>
>           </th>
>           <td align="left">
>             <html:text property="gender" size="4"/>
>           </td>
>         </tr>
>         <tr>
>           <th align="right">
>             <bean:message key="prompt.imHandle"/>
>           </th>
>           <td align="left">
>             <html:text property="imHandle" size="25"/>
>           </td>
>         </tr>
>         <tr>
>           <td align="right">
>             <html:submit>
>               <bean:message key="button.save"/>
>             </html:submit>
>           </td>
>           <td align="left">
>             <html:reset>
>               <bean:message key="button.reset"/>
>             </html:reset>
>           </td>
>         </tr>
>       </table>
>     </html:form>
>   </body>
> </html:html>
>
> web.xml
> =======
> Same as below
>
> ApplicationResources.properties
> ===============================
> Same as below
>
> struts-config.xml
> =================
> <?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">
>
> <!--
>      This is the Struts configuration file for the example application,
>      using the proposed new syntax.
>
>      NOTE:  You would only flesh out the details in the "form-bean"
>      declarations if you had a generator tool that used them to create
>      the corresponding Java classes for you.  Otherwise, you would
>      need only the "form-bean" element itself, with the corresponding
>      "name" and "type" attributes.
> -->
>
> <struts-config>
>
>   <!-- ========== Form Bean Definitions ===================================
> -->
>   <form-beans>
>
>     <!-- Logon form bean -->
>     <form-bean      name="personForm"
>                     type="com.ubermind.bumbletrak.PersonForm"/>
>
>   </form-beans>
>
>   <!-- ========== Global Forward Definitions ==============================
> -->
>   <global-forwards>
>     <forward   name="success"              path="/Success.jsp"/>
>   </global-forwards>
>
>   <!-- ========== Action Mapping Definitions ==============================
> -->
>   <action-mappings>
>
>     <!-- Save a person -->
>     <action    path="/savePerson"
>                type="com.ubermind.bumbletrak.SavePersonAction"
>                name="personForm"
>               scope="request"
>               input="/CreateNewPerson2.jsp">
>     </action>
>
>   </action-mappings>
>
> </struts-config>
>
> PersonForm.java
> ===============
> package com.ubermind.bumbletrak;
>
> import javax.servlet.http.HttpServletRequest;
> import org.apache.struts.action.ActionError;
> import org.apache.struts.action.ActionErrors;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionMapping;
>
> public final class PersonForm extends ActionForm  {
> //    private String action = "Create";
>     private String firstName = null;
>     private String middleName = null;
>     private String lastName = null;
>     private String gender = null;
>     private String imHandle = null;
>
>     public String getFirstName() {
>
>         return (this.firstName);
>
>     }
>
>     public void setFirstName(String aName) {
>
>         this.firstName = aName;
>
>     }
>
>     public String getMiddleName() {
>
>         return (this.middleName);
>
>     }
>
>     public void setMiddleName(String aName) {
>
>         this.middleName = aName;
>
>     }
>
>     public String getLastName() {
>
>         return (this.lastName);
>
>     }
>
>     public void setLastName(String aName) {
>
>         this.lastName = aName;
>
>     }
>
>     public String getGender() {
>
>         return (this.gender);
>
>     }
>
>     public void setGender(String aGender) {
>
>         this.gender = aGender;
>
>     }
>
>     public String getImHandle() {
>
>         return (this.imHandle);
>
>     }
>
>     public void setImHandle(String aHandle) {
>
>         this.imHandle = aHandle;
>
>     }
>
>     /**
>      * Reset all properties to their default values.
>      *
>      * @param mapping The mapping used to select this instance
>      * @param request The servlet request we are processing
>      */
>     public void reset(ActionMapping mapping, HttpServletRequest request) {
>
> //        this.action = "Create";
>         this.firstName = null;
>         this.middleName = null;
>         this.lastName = null;
>         this.gender = null;
>         this.imHandle = null;
>
>     }
>
>     /**
>      * Validate the properties that have been set from this HTTP request,
>      * and return an <code>ActionErrors</code> object that encapsulates any
>      * validation errors that have been found.  If no errors are found,
> return
>      * <code>null</code> or an <code>ActionErrors</code> object with no
>      * recorded error messages.
>      *
>      * @param mapping The mapping used to select this instance
>      * @param request The servlet request we are processing
>      */
>     public ActionErrors validate(ActionMapping mapping,
>                                  HttpServletRequest request) {
>
>         ActionErrors errors = new ActionErrors();
>         if ((firstName == null) || (firstName.length() < 1))
>             errors.add("firstName",
>                        new ActionError("error.firstName.required"));
>         if ((lastName == null) || (lastName.length() < 1))
>             errors.add("lastName",
>                        new ActionError("error.lastName.required"));
>
>         return errors;
>
>     }
>
> }
>
> SavePersonAction.java
> ======================
> package com.ubermind.bumbletrak;
>
> import java.io.IOException;
> import java.lang.reflect.InvocationTargetException;
> import java.util.Locale;
> import java.util.Hashtable;
> import javax.servlet.RequestDispatcher;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpSession;
> import javax.servlet.http.HttpServletResponse;
> import org.apache.struts.action.Action;
> import org.apache.struts.action.ActionError;
> import org.apache.struts.action.ActionErrors;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionForward;
> import org.apache.struts.action.ActionMapping;
> import org.apache.struts.action.ActionServlet;
> import org.apache.struts.util.MessageResources;
> //import org.apache.struts.util.PropertyUtils;
> import com.ubermind.bumbletrak.*;
> import weblogic.jndi.*;
> import java.util.*;
> import javax.naming.*;
> import java.sql.*;
> import java.io.*;
>
> public final class SavePersonAction extends Action {
>
>     public ActionForward perform(ActionMapping mapping,
>                                  ActionForm form,
>                                  HttpServletRequest request,
>                                  HttpServletResponse response)
>         throws IOException, ServletException {
>
>         System.out.println("At the start of perform(...)");
>
>         // Extract attributes and parameters we will need
> //      Locale locale = getLocale(request);
>         MessageResources messages = getResources();
>         HttpSession session = request.getSession();
>         ActionErrors errors = new ActionErrors();
>         PersonForm personForm = (PersonForm) form;
>
>         // Create the person
>         System.out.println(personForm.getFirstName()+"
> "+personForm.getMiddleName()+" "+personForm.getLastName()+" gender =
> "+personForm.getGender()+" IM handle = "+personForm.getImHandle());
>
>         // Remove the obsolete form bean
>         if (mapping.getAttribute() != null) {
>             if ("request".equals(mapping.getScope()))
>                 request.removeAttribute(mapping.getAttribute());
>             else
>                 session.removeAttribute(mapping.getAttribute());
>         }
>
>         // Forward control to the specified success URI
>         if (servlet.getDebug() >= 1)
>             servlet.log(" Forwarding to success page");
>         return (mapping.findForward("success"));
>
>     }
>
> }
>
> "Tim Buchalka" <ti...@buchalka.com> wrote:
> > Hi there Tiff,
> >
> > I'll prefix my recommendations by saying I am far from an expert with the
> > struts framework, but I have managed to get a simple app up and working,
> so
> > hopefully I can help you out a bit.
> >
> > I think the problem may be that you have not defined any actions for your
> > application (I could be wrong, but hey it's worth a try).
> >
> > What I suggest you do is add a "<html:form" command to your jsp, and a
> > couple of fields "<html:text" command.
> >
> > Make sure you put a <html:reset/> in your jsp as well to ensure the form
> > bean get's initialised.
> >
> > If you have no  joy, I'll email my simple app that I setup which consisted
> > of 2 jsps, 2 form beans, and 1 action.
> >
> > If you really want to get what you have currently to work, post the
> contents
> > of your struts-config.xml file.
> >
> > Cheers
> >
> >
> >
> > Tim
> >
> >
> >
> >
> >
> >
> > -----Original Message-----
> > From: Tiffany Dodge [mailto:tiff@ubermind.com]
> > Sent: Friday, 29 June 2001 11:10 AM
> > To: struts-user@jakarta.apache.org
> > Subject: newbie question (again)
> >
> >
> > Hello,
> >
> > I got the struts-example working and have begun trying to implement a
> small
> > test app using struts, but have run into a problem.  Below is the
> exception
> > I'm receiving ...
> >
> > Thu Jun 28 17:32:41 PDT 2001:<E> <WebAppServletContext-bumbletrak> Root
> > cause of
> >  ServletException
> > javax.servlet.ServletException: runtime failure in custom tag 'message'
> >         at
> > jsp_servlet._createnewperson2._jspService(_createnewperson2.java:108)
> >
> >         at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
> >         at
> > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
> > pl.java:106)
> >         at
> > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
> > pl.java:124)
> >         at
> > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
> > textImpl.java:907)
> >         at
> > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
> > textImpl.java:851)
> >         at
> > weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
> > ContextManager.java:252)
> >         at
> > weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
> > a:364)
> >         at
> > weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:252)
> >
> >         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
> >
> > >From searching the mailing list, I think it is due to not finding the
> > ApplicationResources.properties file. Below are the reasons that I found
> > (from the struts-user mailng list) which could cause the problem ...
> >
> > - Not having the <param-name>application</param-name> element in the
> web.xml
> > file.
> > - Miss typing the path for <param-name>application</param-name>'s value.
> Or
> > not placing the ApplicationResources.properties file in the correct
> > directory.
> > - Not having the <load-on-startup> element in the web.xml file.
> > - Having struts.jar in my CLASSPATH.
> >
> > >From what I can tell, I don't have any of the above problems.  But I'm
> > gonna
> > include everything for review so some new/more experienced eyes can look
> at
> > it.
> >
> > CreateNewPerson2.jsp
> > ====================
> > <%@ page language="java"%>
> > <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> > <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> >
> > <html:html locale="true">
> >   <head>
> >     <% System.out.println("Before the title tag."); %>
> >     <title><bean:message key="CreateNewPerson2.title"/></title>
> >     <html:base/>
> >   </head>
> >   <body bgcolor="white">
> >   </body>
> > </html:html>
> >
> >
> > web.xml
> > =======
> > <?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>
> >
> >   <!-- Action Servlet Configuration -->
> >   <servlet>
> >     <servlet-name>action</servlet-name>
> >     <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> >     <init-param>
> >       <param-name>application</param-name>
> >
> > <param-value>com.ubermind.bumbletrak.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>1</load-on-startup>
> >   </servlet>
> >
> >
> >   <!-- Action Servlet Mapping -->
> >   <servlet-mapping>
> >     <servlet-name>action</servlet-name>
> >     <url-pattern>*.do</url-pattern>
> >   </servlet-mapping>
> >
> >
> >   <!-- The Welcome File List -->
> >   <welcome-file-list>
> >     <welcome-file>CreateNewPerson2.jsp</welcome-file>
> >   </welcome-file-list>
> >
> >   <!-- 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>
> >
> >
> > ApplicationResources.properties
> > ===============================
> > button.cancel=Cancel
> > button.confirm=Confirm
> > button.reset=Reset
> > button.save=Save
> > error.fistName.required=<li>First Name is required</li>
> > error.lastName.required=<li>Last Name is required</li>
> > CreateNewPerson2.title=BumbleTrak
> > prompt.firstName=First Name *
> > prompt.lastName=Last Name *
> > prompt.middleName=Middle Name
> > prompt.imHandle=IM Handle
> > prompt.gender=Gender
> >
> >
> >
> > (NOTE: I am using WebLogic 5.1 with SP8)
> >
> > DIRECTORY STRUCTURE
> > ===================
> > CreateNewPerson2.jsp
> > -WEB-INF
> >     _tmp_war_bumbletrak
> >         -com
> >             -ubermind
> >                 -bumbletrak
> >                     ApplicationResources.properties
> >         -jsp_servlet
> >             _createnewperson2.class
> >         struts.jar
> >     -classes
> >         -com
> >             -ubermind
> >                 -bumbletrak
> >                     ApplicationResources.properties
> >     -lib
> >         struts.jar
> >     struts.tld
> >     struts-bean.tld
> >     struts-config.xml
> >     struts-form.tld
> >     struts-html.tld
> >     struts-logic.tld
> >     struts-template.tld
> >     web.xml
> >
> > Please give me any suggestions or comments.  PLEASE!!!!
> >
> > Thanks,
> > Tiff
> >
> >

--
The views expressed by the sender of this message don't
necessarily represent those of Brecon Beacons National Park
Authority. This message is intended for the addressee(s) only
and is sent in confidence; if you receive it in error, please can you
let us know (at it@breconbeacons.org) and then destroy all copies.
Nid yw'r farn a fynegir gan anfonwr y neges hon o anghenraid yn
adlewyrchu barn Awdurdod Parc Cenedlaethol Bannau Brycheiniog.
Neges yw hon a fwriadwyd ar gyfer y derbynnydd/derbynyddion
yn unig ac fe'i hanfonir yn gyfrinachol; os ydych yn ei dderbyn
mewn camgymeriad, a fyddech gystal â rhoi gwybod i
ni (yn it@breconbeacons.org) ac yna dilëwch bob copi.