Reputation: 33
This is my JSP
extra.jsp
:
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<html>
<head>
</head>
<body>
<h1><bean:write name="HelloWorldForm" property="message">
</h1>
</body>
</html>
this formBean
HelloWorldForm.java
:
package com.redhat.rhn.frontend.action.common;
import org.apache.struts.action.ActionForm;
public class HelloWorldForm extends ActionForm{
String message="HelloWorld!";
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
this is action
HelloWorldAction.java
:
package com.redhat.rhn.frontend.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.redhat.rhn.frontend.action.common.HelloWorldForm;
public class HelloWorldAction extends Action{
public ActionForward execute(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
throws Exception {
HelloWorldForm HelloWorldForm = (HelloWorldForm) form;
HelloWorldForm.setMessage("Hello World! Struts");
return mapping.findForward("success");
}
}
I have added following code in struts-config file
struts-config.xml
:
<form-bean name="HelloWorldForm"
type="com.redhat.rhn.frontend.common.HelloWorldForm">
</form-bean>
<action path="/extra"
scope="request"
name="HelloWorldForm"
type="com.redhat.rhn.frontend.action.HelloWorldAction">
<forward name="success" path="/WEB-INF/pages/extra.jsp" />
</action>
I get internal server error when I try to access the extra.jsp from browser The intention behind printing hello world is to get to know how to call java method from jsp
Upvotes: 3
Views: 1051
Reputation: 1
The error code 500 is produced via jasper compiler when compiling JSP page that has errors
The tag
<bean:write name="HelloWorldForm" property="message">
isn't closed and compiler will result the error with 500 status code
Upvotes: 1