Internal server error when calling Java method from JSP

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 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 added the following code to my 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 am getting an internal server error when I try to access extra.jsp from the browser The purpose of Hello World printing is to find out how to call a java method from jsp

+3


source to share


1 answer


Error code 500 is generated via jasper compiler when compiling JSP page with errors

Tag



<bean:write name="HelloWorldForm" property="message"> 

      

does not close and the compiler will throw a 500 error

+1


source







All Articles