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
Win a copy of
Eclipse Collections Categorically: Level up your programming game
this week in the
Open Source Projects
forum!
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
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Struts
Cannot figure out why Formbean is null in this code...
Sean Gildea
Ranch Hand
Posts: 81
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I cannot figure out why my formbean is null. Can someone please take a look at my code and possibly shed some light on what I may be doing wrong?
When I run this, the blogBean object is null with a NPE.
Thanks in advance,
Sean Gildea
---------------
package coreservlets; import javax.servlet.http.*; import org.apache.struts.action.*; public class BlogAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BlogFormBean blogBean = (BlogFormBean)form; String title = blogBean.getTitle(); String entry = blogBean.getEntry(); request.setAttribute("blogBean", blogBean); if ((title == null) || (title.trim().length() < 1)) { return(mapping.findForward("no-entry")); } else if ((entry == null) || (entry.trim().length() < 1)) { return(mapping.findForward("no-entry")); } return(mapping.findForward("blog-success")); } }
SCJD, SCBCD, SCJP
Marc Peabody
pie sneak
Posts: 4727
I like...
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
What does your ActionMapping look like in the struts-config? Did you specify the name attribute to say which ActionForm it uses?
A good workman is known by his tools.
Sean Gildea
Ranch Hand
Posts: 81
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Marc,
I made a mistake in the struts-config.xml, that fixed it, thanks!
<form-beans> <form-bean name="blogFormBean" type="blogdb.BlogFormBean"/> </form-beans> <action-mappings> <action path="/processblog" type="blogdb.BlogAction" name="blogFormBean" scope="request"> <forward name="no-entry" path="/WEB-INF/results/no-entry.jsp"/> <forward name="blog-success" path="/WEB-INF/results/blog-success.jsp"/> </action> </action-mappings>
SCJD, SCBCD, SCJP
To do a great right, do a little wrong - shakepeare. twisted little ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Cannot retrieve mapping for action
struts
confusing compile error
struts
Confused on validate() method
More...