You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by udaykumar <ta...@gmail.com> on 2008/03/13 11:43:23 UTC

How to use the 'struts 1 plugin' in struts2

Hi 

I'm Trying to use ActionForm and Action class in my struts2. I Used the
struts 1 plugin for this. I followed the procedure, which they given. Still
i'm finding error in this. 

I'm giving my entire application here. 

strutslogin.jsp 
------------------- 

<%@ taglib prefix="s" uri="/struts-tags" %> 
<%@ page language="java" contentType="text/html"%> 

<html> 
    <head> 
        <title>Insert Data here!</title> 
     <link href="<s:url value="/css/main.css"/>" rel="stylesheet" 
          type="text/css"/> 
  </head> 
    <body> 
    <s:form action="/struts1/logon.action" method="POST" name="form1"> 
      <s:textfield name="userId" label="Login Id"/><br> 
      <s:password name="password" label="Password"/><br> 
         <s:submit value="Login" align="center"/> 
    </s:form> 
  </body> 
</html> 
---------------------------- 
MyForm.java 
---------------------------- 

package com; 

import org.apache.struts.action.ActionForm; 

public class MyForm extends ActionForm{ 
public String userId; 
public String password; 
public String getUserId() { 
return userId; 
} 
public void setUserId(String userId) { 
this.userId = userId; 
} 
public String getPassword() { 
return password; 
} 
public void setPassword(String password) { 
this.password = password; 
} 

} 
------------------- 
MyAction.java 
--------------------- 
package com; 

import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 

import org.apache.struts.action.Action; 
import org.apache.struts.action.ActionForm; 
import org.apache.struts.action.ActionForward; 
import org.apache.struts.action.ActionMapping; 

public class MyAction extends Action{ 
public ActionForward execute( ActionMapping mapping,ActionForm
form,HttpServletRequest req,HttpServletResponse res) 
{ 
System.out.println("I'm in Struts 1 Action "); 
MyForm form1=(MyForm)form; 
System.out.println(form1.getUserId()); 
return mapping.findForward("success"); 
} 
} 
----------------------- 
struts.xml 
------------------------ 

<package name="udaykumar" namespace="/html2" extends="struts-default"> 

<action name="login"> 
<result>/pages/strutslogin.jsp</result> 
</action> 
</package> 
<package name="struts" namespace="/struts1" extends="struts1-default"> 
<action name="logon" class="org.apache.struts2.s1.Struts1Action"> 
   
  <interceptor-ref name="scopedModelDriven"> 
    com.MyForm 
    form1 
    session 
  </interceptor-ref> 
  <interceptor-ref name="struts1-default"/> 
  com.MyAction 
  <result name="success">/pages/strutsResult.jsp</result> 
</action> 

</package> 



Please provide me the solution. Give me a example for this. 
-- 
View this message in context: http://www.nabble.com/How-to-use-the-%27struts-1-plugin%27-in-struts2-tp16024545p16024545.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to use the 'struts 1 plugin' in struts2

Posted by Dave Newton <ne...@yahoo.com>.
--- udaykumar <ta...@gmail.com> wrote:
> I'm Trying to use ActionForm and Action class in my struts2. I Used the
> struts 1 plugin for this. I followed the procedure, which they given. Still
> i'm finding error in this. 

It would be helpful if you'd tell us *what* error(s). Just saying "it doesn't
work" does not provide enough diagnostic information. Some of your XML didn't
come through so it's also hard to tell exactly what is in your configuration
file.

Dave


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