You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Simons Kevin <fb...@skynet.be> on 2005/09/07 21:29:52 UTC

class file mapping

All,

I am a newbie still testing things out to understand struts better.
I have the following structure :
java files in folder /classes.
class files in folder /classes/test.
This is al normal. I have create a simple index.jsp
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head>
</head>
<body>
<html:form action="/index.do" focus="name">
<table>
<tr>
    <td >Name:</td>
    <td><html:text property="name"/></td>
</tr>
</table>
<html:submit>ok</html:submit>
</html:form>
</body>
</html>

The url is http://localhost:8080/tests/index.jsp.
This loads perfect. When I hit the submit button he changes the url to 
http://localhost:8080/tests/index.do. Up till here I can follow. But then...
Can someone explain me why I need to place my class files also in the 
classes folder. Otherwise he complains about a 500 error (didn't produce a 
class file). When I found that out, I get another 500 No action instance for 
path /index could be created. Apparently this means that my action file does 
not extend the action class but it does.
package test;

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import org.apache.struts.action.ActionForm;

import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public final class insertTestAction extends Action {

public insertTestAction() {}


public ActionForward execute(ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response)

throws Exception {

testService service = new testService();

testForm testForm = (testForm) form;

testDTO testDTO = new testDTO();

BeanUtils.copyProperties( testDTO, testForm );

service.insertTest( testDTO );

request.setAttribute("tests",testDTO);

return (mapping.findForward("success"));

}

}

Can someone tell me a bit more about those two things ( like why these 
happen, what I can do to avoid the errors). The weirdest thing in fact is 
the fact that I need to copy my class files into the classes too, normally 
he should look into the test folder...

Greetz,



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005


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


Re: class file mapping

Posted by Michael Jouravlev <jm...@gmail.com>.
Do you refer to insertTestAction or to test.insertTestAction in your
action mapping? Can you post your action mapping?

Michael.

On 9/7/05, Simons Kevin <fb...@skynet.be> wrote:
> This loads perfect. When I hit the submit button he changes the url to
> http://localhost:8080/tests/index.do. Up till here I can follow. But then...
> Can someone explain me why I need to place my class files also in the
> classes folder. Otherwise he complains about a 500 error (didn't produce a
> class file). When I found that out, I get another 500 No action instance for
> path /index could be created. Apparently this means that my action file does
> not extend the action class but it does.
> package test;
> ...
> public final class insertTestAction extends Action {
> ...
> }

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


Re: class file mapping

Posted by Murray Collingwood <mu...@focus-computing.com.au>.
You don't mention your Struts config file.  Do you have one?

I would suggest you move your java files to a "src" folder but not under the /WEB-INF, 
put them under the project folder, eg "/project/src" alongside "/project/test"  The class 
files should then be compiled into "WEB-INF/classes".

The directory structure of "WEB-INF/classes" for your class files is not an option, it is a 
requirement of Struts.  There are a number of documented directory structures in a 
Struts application and you must adhere to these.  This is how Struts knows to go looking 
in certain places for certain files.  A key one of course is the Struts config file, however 
the location of this is specified in the web.xml, however the location of the web.xml is 
fixed.

Another suggestion, name all of your classes with capital letters and then name 
instances of these with lowercase, it really helps when you get into the coding.  
eg TestService testservice = new TestService();

Kind regards
mc

On 7 Sep 2005 at 21:29, Simons Kevin wrote:

> All,
> 
> I am a newbie still testing things out to understand struts better.
> I have the following structure :
> java files in folder /classes.
> class files in folder /classes/test.
> This is al normal. I have create a simple index.jsp
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <html>
> <head>
> </head>
> <body>
> <html:form action="/index.do" focus="name">
> <table>
> <tr>
>     <td >Name:</td>
>     <td><html:text property="name"/></td>
> </tr>
> </table>
> <html:submit>ok</html:submit>
> </html:form>
> </body>
> </html>
> 
> The url is http://localhost:8080/tests/index.jsp.
> This loads perfect. When I hit the submit button he changes the url to 
> http://localhost:8080/tests/index.do. Up till here I can follow. But then...
> Can someone explain me why I need to place my class files also in the 
> classes folder. Otherwise he complains about a 500 error (didn't produce a 
> class file). When I found that out, I get another 500 No action instance for 
> path /index could be created. Apparently this means that my action file does 
> not extend the action class but it does.
> package test;
> 
> import org.apache.struts.action.Action;
> 
> import org.apache.struts.action.ActionForward;
> 
> import org.apache.struts.action.ActionMapping;
> 
> import org.apache.struts.action.ActionForm;
> 
> import org.apache.commons.beanutils.BeanUtils;
> 
> import javax.servlet.http.HttpServletRequest;
> 
> import javax.servlet.http.HttpServletResponse;
> 
> public final class insertTestAction extends Action {
> 
> public insertTestAction() {}
> 
> 
> public ActionForward execute(ActionMapping mapping,
> 
> ActionForm form,
> 
> HttpServletRequest request,
> 
> HttpServletResponse response)
> 
> throws Exception {
> 
> testService service = new testService();
> 
> testForm testForm = (testForm) form;
> 
> testDTO testDTO = new testDTO();
> 
> BeanUtils.copyProperties( testDTO, testForm );
> 
> service.insertTest( testDTO );
> 
> request.setAttribute("tests",testDTO);
> 
> return (mapping.findForward("success"));
> 
> }
> 
> }
> 
> Can someone tell me a bit more about those two things ( like why these 
> happen, what I can do to avoid the errors). The weirdest thing in fact is 
> the fact that I need to copy my class files into the classes too, normally 
> he should look into the test folder...
> 
> Greetz,
> 
> 
> 
> -- 
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> -- 
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005
> 



FOCUS Computing
Mob: 0415 24 26 24
murray@focus-computing.com.au
http://www.focus-computing.com.au



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.18/91 - Release Date: 6/09/2005


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