• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

new to struts

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am new to struts i want to a sample program in struts,for this i did like following


I did every thing for doing the program in struts like Action clss,web.xml,struts-config.xml

here i am sending my path

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\appstruts\WEB-INF\classes\Aone.java--->this is action class

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\appstruts\WEB-INF\web.xml,struts-config.xml

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\appstruts\WEB-INF\lib\-->here i included related jar files

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">

<struts-config>

<!-- ========== Form Bean Definitions ============ -->
<form-beans>
<form-bean name="login" type="test.struts.LoginForm" />
</form-beans>


<!-- ========== Global Forward Definitions ========= -->
<global-forwards>
</global-forwards>


<!-- ========== Action Mapping Definitions ======== -->
<action-mappings>
<action
path="/actOne"type="Aone" >

<forward name="valid" path="/jsp/MainMenu.jsp" />
<forward name="invalid" path="/jsp/LoginView.jsp" />
</action>
</action-mappings>

</struts-config>

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>test.struts.MessageResources</param-value>
</init-param>
<init-param>
<param-name>mapping</param-name>
<param-value>org.apache.struts.action.RequestActionMapping</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>
<load-on-startup>2</load-on-startup>
</servlet>


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

<!-- Struts Tag Library Descriptors -->


<taglib>
<taglib-uri>/WEB-INF/struts.tld</taglib-uri>
<taglib-location>/WEB-INF/struts.tld</taglib-location>
</taglib>
<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>

<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>

</web-app>

Aone.java

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import org.apache.struts.action.*;
public class Aone extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest req,HttpServlet res)throws Exception
{
System.out.println("----execute of aone---");
return null;
}
}


but when i am going to excute in tomcat its going to another file
i am clicking on the folder appstruts like following

http://localhost:8082/appstruts/

but its directly going to http://localhost:8082/appstruts/example/HelloWorld.action this link
i changed and i typed there like following http://localhost:8082/appstruts/actOne.do
its giving the error uable to find requsted resorce
what to do
where did i mistaked

please any one help me
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you havent made any JSP page ? you need a view component right ? when starting struts download struts-blank.war file from the apache website and try to run the war file put the war file in Tomcat's webapps folder . se struts blank is running or not ( first from your services start tomcat )...if tomcat is starting well then try to run the struts-blank.war
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic