facebook

What is the correct way to call struts in the browser ????

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #219787 Reply

    Here is my strutsconfig.xml
    <?xml version=”1.0″ encoding=”UTF-8″?>
    <!DOCTYPE struts-config PUBLIC “-//Apache Software Foundation//DTD Struts Configuration 1.1//EN” “http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd”&gt;
    <struts-config>
    <data-sources />
    <form-beans >
    <form-bean name=”loginForm” type=”com.yourcompany.struts.form.LoginForm” />
    </form-beans>

    <global-exceptions />
    <global-forwards />
    <action-mappings >
    <action
    attribute=”loginForm”
    input=”/Login.jsp”
    name=”loginForm”
    path=”/login”
    scope=”request”
    type=”com.yourcompany.struts.action.LoginAction”>
    <forward name=”succes” path=”/Userlogin.jsp” />
    <forward name=”failure” path=”/Login.jsp” />
    </action>
    </action-mappings>
    <controller bufferSize=”4096″ debug=”0″ />
    <message-resources parameter=”com.yourcompany.struts.ApplicationResources” />
    </struts-config>

    ************************************************************
    when I do http://localhost:8400/TEST/login/Login.jsp
    I get the following errors
    http 404 the page could not be found.
    when I do http://localhost:8400/TEST/Login.jsp
    it works fine.
    My confusion is that as I have /login in strutsconfig path the correct way to call should be http://localhost:8400/TEST/login/Login.jsp but it doesn’t work.
    also when http://localhost:8400/TEST/Login.jsp ant it works and I click on the submit button nothing happen.
    Here is my jsp

    <%@ page language=”java”%>

    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-bean&#8221; prefix=”bean” %>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-html&#8221; prefix=”html” %>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-logic&#8221; prefix=”logic” %>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-tiles&#8221; prefix=”tiles” %>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-template&#8221; prefix=”template” %>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-nested&#8221; prefix=”nested” %>

    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
    <html:html locale=”true”>
    <head>
    <html:base />
    <title>Login.jsp</title>
    <meta http-equiv=”pragma” content=”no-cache”>
    <meta http-equiv=”cache-control” content=”no-cache”>
    <meta http-equiv=”expires” content=”0″>
    <meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>
    <meta http-equiv=”description” content=”This is my page”>
    </head>
    <body>
    <html:form action=”login” >
    password : <html:text property=”password”/>
    <html:errors property=”password”/></br>
    userName : <html:text property=”userName”/>
    <html:errors property=”userName”/></br>
    <html:submit/><html:cancel/>
    </html:form>

    </body>
    </html:html>

    #219788 Reply

    Riyad Kalla
    Member

    jean,
    Assuming you used the default path mapping in your web.xml file, the way you call this action is http://localhost:8400/TEST/login.do, that .do will trigger the ActionServlet from Struts to parse off the “.do” part and then look in the struts-config.xml file for anything matching “/login”, it will find your action and execute it. You will most likely want people to go to your Login.jsp page first, and you will have your form’s action path poin to “/login.do” so that your login form’s data will be sent to your Action. I suggest picking up Struts in Action as its an excellent book when getting started with Struts, you can grab the eBook from manning or Amazon for $22 or so.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: What is the correct way to call struts in the browser ????

You must be logged in to post in the forum log in