You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Paul Goepfert <pa...@gmail.com> on 2005/06/02 21:08:07 UTC

Having trouble moving between velocity pages with struts

Here it is,  I am developing a small program  that utilizes Struts, Java 
and Apache Velocity Templates.  I am trying to move from one page to 
another via struts.  Every time I try to move to another page I get a 
404 Error in Tomcat.  Here is my struts-conf.xml file as well as my 
web.xml file.  Could someone please tell me what is wrng with it.

<struts-config>
       <form-beans>
               <form-bean name="infoForm" type="forms.InfoForm">
       <form-beans>
       <action-mappings>
               <action         path="/PersonalInfo"
                               type="actions.InfoAction"
                               name="infoForm">
                       <forward name="success" path="/info.vm" />
                       <forward name="failure" path="/menu.vm" />
               </action>
       </action-mappings>
<struts-config>

<web-app>
       <display-name>Personal Information</display-name>
       <servlet>
               <servlet-name>action</servlet-name>
             
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
               <init-parm>
                       <parm-name>config</parm-name>
                   <parm-value>/WEB-INF/conf/struts-conf.xml</parm-value>
               </init-parm>
               <load-on-startup>2</load-on-startup>
       </servlet>
       <servlet>
               <servlet-name>velocity</servlet-name>
               
<servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class> 

               <load-on-startup>10</load-on-startup>
       </servlet>
       <servlet-mapping>
               <servlet-name>velocity</servlet-name>
               <url-pattern>*.vm</url-pattern>
       <servlet-mapping>
               <servlet-name>action</servlet-name>
               <url-pattern>*.do</url-pattern>
       </servlet-mapping>
</web-app>

The servlet-class for "action" is not the same class for where my 
servlet is located.  Anonther thing that I don't understand is the *.do 
url-mapping If anyone can explain that to me that would be great.

What I  mean by moving between pages is that when I click on a button I 
get a 404 error.  I should move to another page.  

Thanks

Paul

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


Re: Having trouble moving between velocity pages with struts

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Paul,

> I have a question about the velstruts.war file.  I found the file an
> deployed it.  I looked at the source files and the velocity templates.
> The only thing I can't find is where they define the stuff like "title"
> or "intro"  from the first application template.  If someone could tell
> me where that is located that would be great.  If it exists.

They are defined in a message resource file.  Search for *.properties
in the code base.  Some further readings:
  http://struts.apache.org/userGuide/configuration.html#resources_config
  http://jakarta.apache.org/velocity/tools/struts/index.html
  http://jakarta.apache.org/velocity/tools/struts/MessageTool.html

Best regards,
-- Shinobu

--
Shinobu Kawai <sh...@gmail.com>

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


Re: Having trouble moving between velocity pages with struts

Posted by Paul Goepfert <pa...@gmail.com>.
I have a question about the velstruts.war file.  I found the file an 
deployed it.  I looked at the source files and the velocity templates.  
The only thing I can't find is where they define the stuff like "title" 
or "intro"  from the first application template.  If someone could tell 
me where that is located that would be great.  If it exists.

Paul
Shinobu Kawai wrote:

>Hi Paul,
>
>  
>
>>I am using Struts 1.1 and  Velocity tools 1.1
>>    
>>
>
>OK, that part's good.
>
>  
>
>>In my Velocity document I am setting my URL like this:
>>
>><form action="InfoAction.do" method="post">
>>. . .
>></form>
>>
>>InfoAction is the Servlet that performs the Actions on the buttons.
>>
>>My webaddress comes out to be  /PersonalInfo/InfoAction.do
>>I get a 404  error page that  says that Servlet action not available.
>>    
>>
>
>According to your original post, you haven't defined "InfoAction" in
>your struts-config.xml.  Check out the Struts user guide on how do add
>new actions.
>  http://struts.apache.org/userGuide/index.html
>
>Also you might want to check out the velstruts.war for an example of
>how you can use Struts and Velocity together.
>
>Best regards,
>-- Shinobu
>
>--
>Shinobu Kawai <sh...@gmail.com>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>  
>


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


Re: Having trouble moving between velocity pages with struts

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Paul,

> I am using Struts 1.1 and  Velocity tools 1.1

OK, that part's good.

> In my Velocity document I am setting my URL like this:
> 
> <form action="InfoAction.do" method="post">
> . . .
> </form>
> 
> InfoAction is the Servlet that performs the Actions on the buttons.
> 
> My webaddress comes out to be  /PersonalInfo/InfoAction.do
> I get a 404  error page that  says that Servlet action not available.

According to your original post, you haven't defined "InfoAction" in
your struts-config.xml.  Check out the Struts user guide on how do add
new actions.
  http://struts.apache.org/userGuide/index.html

Also you might want to check out the velstruts.war for an example of
how you can use Struts and Velocity together.

Best regards,
-- Shinobu

--
Shinobu Kawai <sh...@gmail.com>

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


Re: Having trouble moving between velocity pages with struts

Posted by Paul Goepfert <pa...@gmail.com>.
I am using Struts 1.1 and  Velocity tools 1.1

In my Velocity document I am setting my URL like this:

<form action="InfoAction.do" method="post">
. . .
</form>

InfoAction is the Servlet that performs the Actions on the buttons.

My webaddress comes out to be  /PersonalInfo/InfoAction.do 
I get a 404  error page that  says that Servlet action not available.

Paul

Shinobu Kawai wrote:

>Hi Paul,
>
>  
>
>>Here it is,  I am developing a small program  that utilizes Struts, Java
>>and Apache Velocity Templates.  I am trying to move from one page to
>>another via struts.  Every time I try to move to another page I get a
>>404 Error in Tomcat.  Here is my struts-conf.xml file as well as my
>>web.xml file.  Could someone please tell me what is wrng with it.
>>    
>>
>
>How are you setting the URL in your template?  The output is likely an
>invalid URL.  What does the URL in your output page look like?
>
>Also, what versions of Struts and VelocityTools are you using?  For
>Struts 1.2, you should use VelocityTools 1.2, which is still under
>development.  You can get nightly snapshots here:
>  http://cvs.apache.org/snapshots/velocity-tools/
>
>Best regards,
>-- Shinobu
>
>--
>Shinobu Kawai <sh...@gmail.com>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>  
>


Re: Having trouble moving between velocity pages with struts

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Paul,

> Here it is,  I am developing a small program  that utilizes Struts, Java
> and Apache Velocity Templates.  I am trying to move from one page to
> another via struts.  Every time I try to move to another page I get a
> 404 Error in Tomcat.  Here is my struts-conf.xml file as well as my
> web.xml file.  Could someone please tell me what is wrng with it.

How are you setting the URL in your template?  The output is likely an
invalid URL.  What does the URL in your output page look like?

Also, what versions of Struts and VelocityTools are you using?  For
Struts 1.2, you should use VelocityTools 1.2, which is still under
development.  You can get nightly snapshots here:
  http://cvs.apache.org/snapshots/velocity-tools/

Best regards,
-- Shinobu

--
Shinobu Kawai <sh...@gmail.com>

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


Re: Having trouble moving between velocity pages with struts

Posted by Nathan Bubna <nb...@gmail.com>.
On 6/2/05, Paul Goepfert <pa...@gmail.com> wrote:
...
> <web-app>
>        <display-name>Personal Information</display-name>
>        <servlet>
>                <servlet-name>action</servlet-name>
> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
>                <init-parm>
>                        <parm-name>config</parm-name>
>                    <parm-value>/WEB-INF/conf/struts-conf.xml</parm-value>
>                </init-parm>
>                <load-on-startup>2</load-on-startup>
>        </servlet>
>        <servlet>
>                <servlet-name>velocity</servlet-name>
> <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
>                <load-on-startup>10</load-on-startup>
>        </servlet>
>        <servlet-mapping>
>                <servlet-name>velocity</servlet-name>
>                <url-pattern>*.vm</url-pattern>
>        <servlet-mapping>
>                <servlet-name>action</servlet-name>
>                <url-pattern>*.do</url-pattern>
>        </servlet-mapping>
> </web-app>
> 
> The servlet-class for "action" is not the same class for where my
> servlet is located.  Anonther thing that I don't understand is the *.do
> url-mapping If anyone can explain that to me that would be great.

*.do should be mapped to Struts' ActionServlet, not the VelocityViewServlet.

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