Link to home
Start Free TrialLog in
Avatar of prsubject
prsubjectFlag for India

asked on

Struts Action Class returning blank page

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
Avatar of Suraj_Mathew
Suraj_Mathew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of prsubject

ASKER

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.
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
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 ?
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?