• 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

Can't strut with struts!

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"));

}

}
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the Struts forum.
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What should I be observing when I view source for ValidatEmployee.do?
 
Robert Bonslater
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
Robert Bonslater
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marc, it worked!!!

Thanks but, can you give an explanation. I replaced the perform method with execute like you said.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic