Re: struts+Action+netbeans 5.0 problem

2006-09-11 Thread Tom Jerry

I got the same thing.. but I figured out the mistake that I used perform( )
instead of execute( ) method. After replacing it with execute ( ) method, I
got the output. There is one more thing.. If you use ActionErrors validate (
) method, then you have to set the validate attribute to "true" right ? ok..
still you have nothing to validate. ok.. leave it.

 You can refer to the url :
http://www.theserverside.com/tt/articles/article.tss?l=StrutsActionMapping
which indicates the ways of mapping for a better output.


Re: struts+Action+netbeans 5.0 problem

2006-09-11 Thread leo mj
give ur jsp code...

krishan rathi <[EMAIL PROTECTED]> wrote: Hi all
   
  I am trying to use struts with netbeans 5.0 but having strange problems.
   
  I have wrtten One ActionForm i.e EmployeeForm ,one action i.e AddEmpAction.
   
  then in the struts-config.xml provided following entries:
   
  
   
  


   
  and using /addEmployee.jsp as welcomefile.
   
  But when i run my application it is displaying the addemployee.jsp correctly 
but when i click on the submit button it just displays a blank screen showing 
addemp.do in the address bar.
   
  can anybody provide what i am missing.
   
  the listing of my formbean and action class is following.
   
  import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
  /**
 *
 * @author admin
 */
public class AddEmpAction extends Action{

   public ActionForward excecute(ActionMapping mapping,ActionForm 
form,HttpServletRequest request,HttpServletResponse response){
  try{
  System.out.println("inside 
action**");
  EmployeeForm empForm=(EmployeeForm)form;
   String name=empForm.getName();
  float salary=empForm.getSalary();
   String address=empForm.getAddress();
   Employee emp=new Employee(name,salary,address);
   EmployeeDao dao=new EmployeeDao();
   dao.insertEmployee(emp,1);
  
  }
  catch(Exception e){
  e.printStackTrace();
  }
  return mapping.findForward("success");
   }

}
   
   
   
   
  /*
 * EmployeeForm.java
 *
 * Created on September 11, 2006, 11:52 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
  package com.myapp.struts.forms;
  import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
  /**
 *
 * @author admin
 */
public class EmployeeForm extends ActionForm {
private String name;
private float salary;
private String address;
  
public void reset(ActionMapping mapping,HttpServletRequest request){
setName(null);
setSalary(0.0F);
setAddress(null);
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request){
return null;
}
public String getName() {
return name;
}
  public void setName(String name) {
this.name = name;
}
  public float getSalary() {
return salary;
}
  public void setSalary(float salary) {
this.salary = salary;
}
  public String getAddress() {
return address;
}
  public void setAddress(String address) {
this.address = address;
}
}
   
   
  thanks
   
  Krishan rathi. 

   
-
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates 
starting at 1¢/min.


-
Get your email and more, right on the  new Yahoo.com 

Re: struts+Action+netbeans 5.0 problem

2006-09-11 Thread nuwan chandrasoma

Hi,

What is the output on the console or messages on the log file?

Thanks,

Nuwan

On 9/11/06, krishan rathi <[EMAIL PROTECTED]> wrote:


Hi all

  I am trying to use struts with netbeans 5.0 but having strange problems.

  I have wrtten One ActionForm i.e EmployeeForm ,one action i.eAddEmpAction.

  then in the struts-config.xml provided following entries:

  

  



  and using /addEmployee.jsp as welcomefile.

  But when i run my application it is displaying the addemployee.jspcorrectly 
but when i click on the submit button it just displays a blank
screen showing addemp.do in the address bar.

  can anybody provide what i am missing.

  the listing of my formbean and action class is following.

  import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
  /**
*
* @author admin
*/
public class AddEmpAction extends Action{

   public ActionForward excecute(ActionMapping mapping,ActionForm
form,HttpServletRequest request,HttpServletResponse response){
  try{
  System.out.println("inside
action**");
  EmployeeForm empForm=(EmployeeForm)form;
   String name=empForm.getName();
  float salary=empForm.getSalary();
   String address=empForm.getAddress();
   Employee emp=new Employee(name,salary,address);
   EmployeeDao dao=new EmployeeDao();
   dao.insertEmployee(emp,1);

  }
  catch(Exception e){
  e.printStackTrace();
  }
  return mapping.findForward("success");
   }

}




  /*
* EmployeeForm.java
*
* Created on September 11, 2006, 11:52 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
  package com.myapp.struts.forms;
  import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
  /**
*
* @author admin
*/
public class EmployeeForm extends ActionForm {
private String name;
private float salary;
private String address;

public void reset(ActionMapping mapping,HttpServletRequest request){
setName(null);
setSalary(0.0F);
setAddress(null);
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest
request){
return null;
}
public String getName() {
return name;
}
  public void setName(String name) {
this.name = name;
}
  public float getSalary() {
return salary;
}
  public void setSalary(float salary) {
this.salary = salary;
}
  public String getAddress() {
return address;
}
  public void setAddress(String address) {
this.address = address;
}
}


  thanks

  Krishan rathi.


-
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great
rates starting at 1¢/min.



struts+Action+netbeans 5.0 problem

2006-09-11 Thread krishan rathi
Hi all
   
  I am trying to use struts with netbeans 5.0 but having strange problems.
   
  I have wrtten One ActionForm i.e EmployeeForm ,one action i.e AddEmpAction.
   
  then in the struts-config.xml provided following entries:
   
  
   
  


   
  and using /addEmployee.jsp as welcomefile.
   
  But when i run my application it is displaying the addemployee.jsp correctly 
but when i click on the submit button it just displays a blank screen showing 
addemp.do in the address bar.
   
  can anybody provide what i am missing.
   
  the listing of my formbean and action class is following.
   
  import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
  /**
 *
 * @author admin
 */
public class AddEmpAction extends Action{

   public ActionForward excecute(ActionMapping mapping,ActionForm 
form,HttpServletRequest request,HttpServletResponse response){
  try{
  System.out.println("inside 
action**");
  EmployeeForm empForm=(EmployeeForm)form;
   String name=empForm.getName();
  float salary=empForm.getSalary();
   String address=empForm.getAddress();
   Employee emp=new Employee(name,salary,address);
   EmployeeDao dao=new EmployeeDao();
   dao.insertEmployee(emp,1);
  
  }
  catch(Exception e){
  e.printStackTrace();
  }
  return mapping.findForward("success");
   }

}
   
   
   
   
  /*
 * EmployeeForm.java
 *
 * Created on September 11, 2006, 11:52 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
  package com.myapp.struts.forms;
  import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
  /**
 *
 * @author admin
 */
public class EmployeeForm extends ActionForm {
private String name;
private float salary;
private String address;
  
public void reset(ActionMapping mapping,HttpServletRequest request){
setName(null);
setSalary(0.0F);
setAddress(null);
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request){
return null;
}
public String getName() {
return name;
}
  public void setName(String name) {
this.name = name;
}
  public float getSalary() {
return salary;
}
  public void setSalary(float salary) {
this.salary = salary;
}
  public String getAddress() {
return address;
}
  public void setAddress(String address) {
this.address = address;
}
}
   
   
  thanks
   
  Krishan rathi. 


-
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates 
starting at 1¢/min.