You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by krishan rathi <kr...@yahoo.com> on 2006/09/11 13:17:36 UTC
struts+Action+netbeans 5.0 problem
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:
<form-bean type="com.myapp.struts.forms.EmployeeForm" name="employee"/>
<action input="/addEmployee.jsp" type="com.myapp.struts.actions.AddEmpAction" validate="false" scope="session" path="/addemp" name="employee">
<forward path="/index.jsp" name="success"/>
</action>
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.
Re: struts+Action+netbeans 5.0 problem
Posted by nuwan chandrasoma <my...@gmail.com>.
Hi,
What is the output on the console or messages on the log file?
Thanks,
Nuwan
On 9/11/06, krishan rathi <kr...@yahoo.com> 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:
>
> <form-bean type="com.myapp.struts.forms.EmployeeForm" name="employee"/>
>
> <action input="/addEmployee.jsp" type="
> com.myapp.struts.actions.AddEmpAction" validate="false" scope="session"
> path="/addemp" name="employee">
> <forward path="/index.jsp" name="success"/>
> </action>
>
> 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.
>
Re: struts+Action+netbeans 5.0 problem
Posted by Tom Jerry <to...@gmail.com>.
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: Constructor of Action is executed but getting a blank screen
Posted by David Grundberg <c0...@cs.umu.se>.
Try overriding "execute", not "excecute" :)
krishan rathi wrote:
>hi all
>
> Infact the constructor of Action is called but i am getting a blank screen and in the log file just getting the SOP in the constructor not even getting the Sop in the Exceute method.
>
> plz help
>
> Thanks
>
>krishan rathi <kr...@yahoo.com> 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.
>
>
>---------------------------------
>How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Constructor of Action is executed but getting a blank screen
Posted by krishan rathi <kr...@yahoo.com>.
thanks
Emilia Ipate <ei...@nl.swets.com> wrote: Hi!
It might sound stupid, but just check: Your execute method from Action is actually called "excecute" instead of "execute".
-----Original Message-----
From: krishan rathi [mailto:kris_rathi79@yahoo.com]
Sent: Monday, September 11, 2006 1:33 PM
To: Struts Users Mailing List
Subject: Constructor of Action is executed but getting a blank screen
hi all
Infact the constructor of Action is called but i am getting a blank screen and in the log file just getting the SOP in the constructor not even getting the Sop in the Exceute method.
plz help
Thanks
krishan rathi 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.
---------------------------------
How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------
All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.
RE: Constructor of Action is executed but getting a blank screen
Posted by Emilia Ipate <ei...@nl.swets.com>.
Hi!
It might sound stupid, but just check: Your execute method from Action is actually called "excecute" instead of "execute".
-----Original Message-----
From: krishan rathi [mailto:kris_rathi79@yahoo.com]
Sent: Monday, September 11, 2006 1:33 PM
To: Struts Users Mailing List
Subject: Constructor of Action is executed but getting a blank screen
hi all
Infact the constructor of Action is called but i am getting a blank screen and in the log file just getting the SOP in the constructor not even getting the Sop in the Exceute method.
plz help
Thanks
krishan rathi <kr...@yahoo.com> 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.
---------------------------------
How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Constructor of Action is executed but getting a blank screen
Posted by krishan rathi <kr...@yahoo.com>.
hi all
Infact the constructor of Action is called but i am getting a blank screen and in the log file just getting the SOP in the constructor not even getting the Sop in the Exceute method.
plz help
Thanks
krishan rathi <kr...@yahoo.com> 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.
---------------------------------
How low will we go? Check out Yahoo! Messengers low PC-to-Phone call rates.
Re: struts+Action+netbeans 5.0 problem
Posted by leo mj <le...@yahoo.com>.
give ur jsp code...
krishan rathi <kr...@yahoo.com> 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