Getting problem in running my first struts porgram

Discussions

Web tier: servlets, JSP, Web frameworks: Getting problem in running my first struts porgram

  1. Getting problem in running my first struts porgram (6 messages)

    My problem is i am getting this erro when i am trying to run my first struts programe can any body help error is:

    please help me this is very urgent

    org.apache.jasper.JasperException: /strutsEx/index.jsp(4,0) Attribute name invalid according to the specified TLD
        at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
        at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:417)
        at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:186)
        at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:498)
        at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:707)
        at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
        at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1070)
        at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1076)
        at org.apache.jasper.compiler.Node$Root.accept(Node.java:232)
        at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
        at org.apache.jasper.compiler.Validator.validate(Validator.java:607)
        at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:222)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
        at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:471)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
        at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
        at java.lang.Thread.run(Thread.java:536)


    I have coppied all the jar file and perfectly written web.xml file and struts-html files there are as follows


    web.xml file

    <!--Standard Action Servlet Configuration
        -->
        <servlet>
            <servlet-name>
                action
            </servlet-name>
            <servlet-class>
                org.apache.struts.action.ActionServlet
            </servlet-class>
            <init-param>
                    <param-name>config</param-name>
                    <param-value>/WEB-INF/struts-config.xml</param-value>
            </init-param>
                <load-on-startup>1</load-on-startup>

        </servlet>

    <!--Standard Action Servlet Configuration
        -->
        <servlet-mapping>
            <servlet-name>
               action
            </servlet-name>
            <url-pattern>
                *.do
            </url-pattern>
        </servlet-mapping>

    <taglib-uri>
                myTagUri
            </taglib-uri>
            <taglib-location>
               /WEB-INF/sureshtaglibs/taglibEx.tld
            </taglib-location>
        </taglib>


    and the struts-config.xml is
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
              "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
        
        <form-beans>
            <form-bean name="lookupForm" type="ch03.lookupForm" />
        </form-beans>
       
        <action-mappings>
            <action path="/loookup" type="ch03.lookupAction" name="lookupForm">
                  <forward name="success" path="/result.jsp"/>
                  <forward name="success" path="/index.jsp"/>
            </action>
        </action-mappings>
    </struts-config>



    my file are Index.jsp

    <%@ page language = "java"%>
    <%@ taglib uri="myTagStruts-Html" prefix="html" %>
    <html>
    <body>
    <html:form action = "lookup" name = "lookupForm" type = "ch03.lookupForm">
        <table>
            <tbody>
                <tr>
                    <td>Name:</td>
                    <td><html:text property = "symbol" /></td>
                    
                </tr>
                <tr>
                    <td colspan = "2" align = "center"><html:submit /></td>
                </tr>
            </tbody>
        </table>
    </html:form>
    </body>
    </html>


    lookupForm.java

    package ch03;
    import javax.servlet.http.*;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;

    public class lookupForm extends ActionForm {
        private String symbol;

        public void setSymbol (String symbol) {
            this.symbol = symbol;
        }

        public String getSymbol () {
            return symbol;
        }

        public void reset (ActionMapping map,HttpServletRequest req) {
            this.symbol = null;
        }
    }

    lookupAction.java

    package ch03;
    import java.io.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    public class lookupAction extends Action {
        
        protected String getQuote (String symbol) {
            if (symbol.equalsIgnoreCase ("suresh")) {
                return "Sucess";
            }
            return "notsucess";
        }

        public ActionForward execute (ActionMapping mapping,ActionForm form,
            HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {

            String result = "notsucess";
            String target = new String ("sucess");
            if (form != null) {
                lookupForm lpForm = (lookupForm)form;
                String symbol = lpForm.getSymbol ();
                result = getQuote (symbol);
            }

            if (result.equals("notsecess")) {
                target = new String ("failure");
            }
            else {
                req.setAttribute ("result",result);
            }
            return (mapping.findForward (target));
        }

    }


    result.html


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>

    <BODY>
        <table>
            <tbody>
                <tr>
                    <td><h5> The output was</h5><%= request.getAttribute ("result")%></td>
                </tr>
                
            </tbody>
        </table>
    </BODY>
    </HTML>
  2. "name" and "type" are not supported for the <html:form/> tag.


    http://struts.apache.org/userGuide/struts-html.html#form
  3. org.apache.jasper.JasperException: Cannot retrieve mapping for action /lookup


    i have chenged the form tag to
    <html:form action = "lookup">
  4. Mr.Kishore please help meeeeee[ Go to top ]

    Mr.Kishore please help meeeeee
  5. path is loookup and not lookup[ Go to top ]

    <action-mappings>
            <action path="/loookup" type="ch03.lookupAction" name="lookupForm">
                  <forward name="success" path="/result.jsp"/>
                  <forward name="success" path="/index.jsp"/>
            </action>
        </action-mappings>

    path is "loookup" and you are trying to lookup "lookup" and so the exception
  6. i have stored my jsp pages in

    webapps\examples\strutsEx\index.jsp &&
    webapps\examples\strutsEx\result.jsp

    i have stores by lookuoForm and lookupAction in WEB-INF\classes\ch03 directory


    i have update my struts-config.xml

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
              "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>

    <form-beans>
    <form-bean name="lookupForm" type="ch03.lookupForm" />
        </form-beans>
       
    <action-mappings>
    <action path="/lookup" type="ch03.lookupAction" name="lookupForm">
    <forward name="success" path="/strutsEx/result.jsp"/>
    <forward name="failure" path="/strutsEx/index1.jsp"/>
    </action>
    </action-mappings>
    </struts-config>


    when i am clicking submit button i am not getting output i am getting blank page different page lookup.do

    what is the problem can u help me please
  7. Mr.Kishore
    Thanq For ur valuable sugessions i have done it may i have ur mail id plzzzzzzzzzzz for future correspondence