struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hajratwala, Nayan (N.)" <nhajr...@ford.com>
Subject RE: how to invoke the action servlet?
Date Thu, 27 Mar 2003 20:42:00 GMT
I think you'll want to go to http://localhost:8080/ginsu/ginsu.do

The first "ginsu" is the name of your webapp, the second "ginsu.do" part will invoke the ActionServlet.
 This is because your web.xml indicates that anything with *.do should go to the ActionServlet.

The ActionServlet will check the struts-config.xml file and see that since you are looking
for ginsu.do, it should find the action named "ginsu", which is your first defined action-mapping.

Hope this helps!

---
- Nayan Hajratwala
- Chikli Consulting LLC
- http://www.chikli.com


-----Original Message-----
From: Dan Tarkenton [mailto:tark_dev@yahoo.com] 
Sent: Thursday, March 27, 2003 3:32 PM
To: struts-user@jakarta.apache.org
Subject: how to invoke the action servlet?



I have been referencing the book Struts in Action by Ted Husted as well as the struts site.
I cannot figure out what to point my browser to in order to invoke struts. I have zero JSPs
in my struts application -- I have no need for them because I am utilizing Model X where I
have one XSLT servlet that represents my entire view layer. I thought I could just point my
browser to http://localhost:8080/ginsu (ginsu being the name of my web app). I realize I have
no index.html or index.jsp, but I'm just trying to go directly to the action servlet from
the browser. 

Is this not possible in struts? 


Here is my struts-config file: 


<snippet> 
<?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> 

<!-- Example logon form bean 
<form-bean name="logonForm" 
type="org.apache.struts.example.LogonForm"/> 
--> 
<form-bean name="contentForm" type="ginsu.ContentForm" /> 

</form-beans> 

<!-- ========== Global Forward Definitions ============================== --> 
<global-forwards> 
<!-- Example logon forward 
<forward name="logon" path="/logon.jsp"/> 
--> 
</global-forwards> 
<!-- ========== Action Mapping Definitions ============================== --> 
<action-mappings> 

<action path="/ginsu" 
type="ginsu.ContentAction" 
name="contentForm"> 
<!-- we want the xslServlet forward path attribute to point to XSL Servlet --> 
<forward name="xslServlet" path="/XSLServlet" /> 
</action> 

<action path="/admin/addFormBean" 
type="org.apache.struts.actions.AddFormBeanAction"/> 
<action path="/admin/addForward" 
type="org.apache.struts.actions.AddForwardAction"/> 
<action path="/admin/addMapping" 
type="org.apache.struts.actions.AddMappingAction"/> 
<action path="/admin/reload" 
type="org.apache.struts.actions.ReloadAction"/> 
<action path="/admin/removeFormBean" 
type="org.apache.struts.actions.RemoveFormBeanAction"/> 
<action path="/admin/removeForward" 
type="org.apache.struts.actions.RemoveForwardAction"/> 
<action path="/admin/removeMapping" 
type="org.apache.struts.actions.RemoveMappingAction"/> 
</action-mappings> 
</struts-config> 

</snippet>


And here is my web.xml file: 


<?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> 
<!-- Standard Action Servlet Configuration (with debugging) --> 
<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> 
<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> 
<load-on-startup>2</load-on-startup> 
</servlet> 
<!-- XSLT Servlet (View component)--> 
<servlet> 
<servlet-name>XSLServlet</servlet-name> 
<servlet-class>ginsu.XSLServlet</servlet-class> 
<!-- <init-param> 
<param-name>xsl-file</param-name> 
<param-value>/WEB-INF/test.xsl</param-value> 
</init-param> 
<load-on-startup>1</load-on-startup> --> 
</servlet> 

<!-- XSLTServlet Mapping --> 
<servlet-mapping> 
<servlet-name>XSLServlet</servlet-name> 
<url-pattern>/XSLServlet</url-pattern> 
</servlet-mapping> 

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



<!-- The Usual Welcome File List --> 
<welcome-file-list> 
<welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 


<!-- Struts Tag Library Descriptors --> 
<taglib> 
<taglib-uri>/tags/struts-bean</taglib-uri> 
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location> 
</taglib> 

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

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

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

<taglib> 
<taglib-uri>/tags/struts-tiles</taglib-uri> 
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location> 
</taglib> 

</web-app> 
</snippet> 


I noticed that there is an element: 


<welcome-file-list> 
<welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 


Is this an absolutely necessary element in the web.xml file? I figure the index.jsp would
just contain a redirect to the action servlet. 


Any help is appreciated. Thanks!



---------------------------------
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message