wood burning stoves*
The moose likes Struts and the fly likes Can't strut with struts! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can Watch "Can New topic
Author

Can't strut with struts!

Robert Bonslater
Greenhorn

Joined: Jan 30, 2005
Posts: 28
Every time I call "ValidateEmployee.do" in my inputContent.jsp it directs me to a blank white page on ie with this URL:

http://localhost:8080/begjsp-ch18/validateEmployee.do;jsessionid=32...

It should either go to the outputContent.jsp or revert back to inputContent.jsp containing the errors from MessageResources.properties. ActionServlet obviously found the mapping so I'm not sure what it could possibly be. I am using Tomcat v5 on windows os with the latest version of jakarata struts. Here is some of my information not that it would be of any help:


web.xml
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


struts-config.xml
<action path="/validateEmployee"
type="com.example.ValidateEmployeeAction"
name="empForm"
scope="request"
input="/inputContent.jsp"
validate="false">
<forward name="success" path="/outputContent.jsp"/>
</action>

ValidateEmployeeAction.java
public class ValidateEmployeeAction extends Action {

public ActionForward perform(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException {
ActionMessages errors = new ActionMessages();
EmployeeForm empForm = (EmployeeForm)form;
String name = empForm.getName();
if(name.trim().equals("")) {
ActionMessage error = new ActionMessage ("error.missing.name");
errors.add("ActionMessages.GLOBAL_MESSAGE",error);
}
String department = empForm.getDepartment();
if(department.trim().equals("")) {
ActionMessage error = new ActionMessage("error.missing.department");
errors.add("ActionMessages.GLOBAL_MESSAGE",error);
}

String[] skills = empForm.getSkills();
if(skills == null) {
ActionMessage error = new ActionMessage("error.missing.skills");
errors.add("ActionMessages.GLOBAL_MESSAGE",error);
}

if(errors.size() > 0) {
saveErrors(request,errors);
return (new ActionForward(mapping.getInput()));
}

return (mapping.findForward("success"));

}

}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Moving to the Struts forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
View source on the "blank" white page. It sounds like there is a problem with the JSP that is preventing it from rendering correcctly. The URL that you are seeing is likely correct however, as you will not see the name of the JSP in the URL.
Robert Bonslater
Greenhorn

Joined: Jan 30, 2005
Posts: 28
What should I be observing when I view source for ValidatEmployee.do?
Robert Bonslater
Greenhorn

Joined: Jan 30, 2005
Posts: 28
This is what comes up:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

90+% of the time, a blank screen means that the forward returned by the Action is not found in the ActionMapping of your struts-config.
Most everything LOOKS ok, so 1 of 2 things might be happening.
1) The error's forward is incorrect (see below)
2) Your perform method is not getting called for some reason and the default perform method in Struts sends back a null ActionForward.

Try replacing this line:
return (new ActionForward(mapping.getInput()));

with:
return mapping.getInputForward();

and we'll see what happens.

Also, it wouldn't hurt to change the name of your method from "perform" to "execute".


A good workman is known by his tools.
Robert Bonslater
Greenhorn

Joined: Jan 30, 2005
Posts: 28
Marc, it worked!!!

Thanks but, can you give an explanation. I replaced the perform method with execute like you said.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

The perform method was deprecated in 1.1 and gone in 1.2.

In 1.1, if you overrode perform, your code still worked because execute's default implementation was to call the perform method.
 
Don't get me started about those stupid light bulbs.
 
subject: Can't strut with struts!
 
Similar Threads
Cannot display ActionMessages
struts class file error
Not able to see the errors on JSP
ActionMessages?????????
Error Message Not Displaying on JSP(URGENT)