troubleshooting Question

Struts Action Class returning blank page

Avatar of prsubject
prsubjectFlag for India asked on
Java EE
10 Comments2 Solutions1308 ViewsLast Modified:
I was trying to develop an application in struts after a long time. It is loading the welcome page. Once I click on that page the form submits and what ever be the value it returns success. I wrote it to simplify this. It doesnt even have a formbean as I am not doing anything with the form bean values. I simplified to the least. Still it was returning a blank page. I am not able to upload the files. I am pasting the code. There are only four files. 1) Action class, 2) struts-config.xml, 3)register1.jsp, 4)confirm-registration.jsp and in 5)web.xml I pasted the welcome file element  
<welcome-file-list>
  <welcome-file>register1.jsp</welcome-file>
 </welcome-file-list>
//Action class
package demo;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

public class RegisterAction1 extends Action {
	public ActionForward execute(HttpServletRequest request,
			                     HttpServletResponse response,
			                     ActionForm form,
			                     ActionMapping mapping) throws Exception
	{
		return (mapping.findForward("success"));
	}
}

//register1.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body bgcolor="pink">
	<center>
	<h1>New Account Registration</h1>
	<form ACTION="register1.do" method="get">
		Email Address: <input type="text" name="email"/><BR>
		Password:      <input type="password" name="password"/><BR>
		<input type="submit" value="Sign me On"/>
	</form>
	</center>
</body>
</html>

//confirm-registration.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<center>
<h1>You have been registered successfully.</h1>
Congratualtions 
</center>
</body>
</html>

//struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"

                                "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>

	<data-sources></data-sources>

	<form-beans></form-beans>

	<global-exceptions></global-exceptions>

	<global-forwards>

	</global-forwards>

	<action-mappings>

		<action path="/register1"

		        type="demo.RegisterAction1">

			<forward name="success" path="/confirm-registration.jsp"/>

		</action>

	</action-mappings>

	<controller></controller>

</struts-config> 

//web.xml
 <welcome-file-list>
  <welcome-file>register1.jsp</welcome-file>
 </welcome-file-list>

Open in new window

ASKER CERTIFIED SOLUTION
Suraj_Mathew

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros