Struts Action Class returning blank page

prsubject
prsubject used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
In struts-config.xml , can you please try modifying the below line

<action path="/register1"
             type="demo.RegisterAction1">


as


<action path="/register1"
             type="demo.RegisterAction1"
             validate="false"
             scope="request">



Also , please put a System.out.println("1234");   just above return (mapping.findForward("success")); in Action class
just to ensure that the control is entering the action class.
remove

  <global-forwards>  
 
        </global-forwards>

in your struts-config.xml file

Author

Commented:
I tried the debugger statements using System.out.println() and also tried logger statements using log4j. Neither of these statements were displaying on the console. I very much placed them before return statement.

I also removed <global-forward></global-forward> statement from struts-config. Still there was no response. I could only see a blank page if I submit the first welcome page.
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Author

Commented:
Forgot to say I have also replace the action mapping as below
<action path="/register1"
             type="demo.RegisterAction1"
             validate="false"
             scope="request">

It was just showing a blank page.
check the path of confirm-registration.jsp

is it located in webcontent or webContent/jsp

Author

Commented:
it is located in webcontent/confirm-registration.jsp. I also created a pages folder and pasted it in it and gave that path as /pages/confirm-registration.jsp. Either way it is showing a blank page.
Can you paste the URL of blank page ?

Author

Commented:
In the get method email and password values are null. It shouldnt matter because I am not validating any form values. I am just forwarding it to an other page what ever be the input.
What is the url of the blank page that you are getting?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial