Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Struts
Struts Action not Forwarding to jsp........
Sravan Alaparthi
Greenhorn
Posts: 2
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
//Employee FormBean Class
package sravan.strutsprac; public class EmployeeForm { private int employeeid; private String employeename; private int departmentid; public int getEmployeeid() { return employeeid; } public void setEmployeeid(int employeeid) { this.employeeid = employeeid; } public String getEmployeename() { return employeename; } public void setEmployeename(String employeename) { this.employeename = employeename; } public int getDepartmentid() { return departmentid; } public void setDepartmentid(int departmentid) { this.departmentid = departmentid; } }
Employee ActionClass
package sravan.strutsprac; import javax.servlet.http.*; 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 EmployeeAction extends Action { public ActionForward execute(HttpServletRequest req,HttpServletResponse res, ActionMapping mapping,ActionForm form){ System.out.println("Hi its a Success"); return mapping.findForward("success"); } }
Struts
Configuration File
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <data-sources /> <form-beans> <form-bean name="employeeform" type="sravan.strutsprac.EmployeeForm"></form-bean> </form-beans> <global-exceptions /> <global-forwards> <forward name="success" path="/success.jsp"></forward> </global-forwards> <action-mappings> <action attribute="employeeform" input="/include.jsp" name="employeeform" path="/success" type="sravan.strutsprac.EmployeeAction" validate="false"> <set-property property="cancellable" value="false" /> <forward name="success" path="/success.jsp" /> </action> </action-mappings> <message-resources parameter="com.yourcompany.struts.ApplicationResources" /> </struts-config>
When i deploy the Application and press Search button @index.jsp instead of displaying success.jsp it is displaying a blank page with the url:
http://localhost:7001/StrutsPrac/success.do
Any help is greatly appreciated
Sravan Alaparthi
Greenhorn
Posts: 2
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The Problem was the execute method is not being called.......
The Best way is to use Annotations and make sure the execute method is properly Overridden....
for Example in the case of above code: change action class to
@Override public ActionForward execute(ActionMapping mapping, ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws Exception {
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Runing an example struts application
null pointer exception in struts 1.1
Hi i am trying to connect to postgresql database using struts 1.2..i have used datasource
error in my struts application no getter methods
Cannot Find Bean inscope null
More...