This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

.do files are blank

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am new to struts. I have developed a simple application in which the .do file is blank.
The code is as given below.
register.jsp
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="forms"%>
<forms:form action="register">
username<forms:text property="username"/>
password<forms assword property="password1"/>
confirm password<forms assword property="password2"/>
<forms:submit value="register"/>
</forms:form>

success.jsp
<html>
<body>
Success !!
Registration Succeeded!!
</body>
</html>

struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>
<form-beans>
<form-bean name="registerForm" type="app.RegisterForm"/>
</form-beans>
<action-mappings>
<action path="/register" type="app.RegisterAction" name="registerForm" scope="request" input="/register.jsp">
<forward name="success" path="/success.jsp"/>
<forward name="failure" path="/failure.jsp"/>
</action>
</action-mappings></struts-config>

web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
<display-name>Struts Blank Application</display-name>

<!-- Standard Action Servlet Configuration (with debugging) -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>


<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


<!-- The Usual Welcome File List -->
<welcome-file-list>
<welcome-file>register.jsp</welcome-file>
</welcome-file-list>


<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-nested</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-tiles</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>

</web-app>

registerAction.java

// RegisterAction.java

package app;
import org.apache.struts.*;
import javax.servlet.http.*;
import java.io.*;

public class RegisterAction extends Action
{
public ActionForward perform(ActionMapping mapping,ActionForm action,HttpServletRequest req,HttpServletResponse res)
{
/*RegisterForm rf=(RegisterForm)form;
String username=rf.getUsername();
String password1=rf.getPassword1();
String password2=rf.getPassword2();
if(password1.equals(password2))
{
try
{
USerDirectory.getInstance().setUser(username,password1);
return mapping.findForward("success");*/
/*}catch(UserDirectoryException e)
{
return mapping.findForward("failure");
}
}*/
return mapping.findForward("failure");

}
}

registerForm

// RegisterForm.java

package app;
import org.apache.struts.*;
public class RegisterForm extends ActionForm
{
protected String username;
protected String password1;
protected String password2;

public String getUsername()
{
return username;
}
public String getPassword1()
{
return password1;
}
public String getPassword2()
{
return password2;
}

public void setUsername(String username)
{
this.username=username;
}
public void setPassword1(String password1)
{
this.password1=password1;
}
public void setPassword2(String password2)
{
this.password2=password2;
}
}


Please help
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the problem is with the Taglib URI.



The uri specified in <taglib-uri> in web.xml and the uri specified in <%@ taglib> directive shopuld be same

Hope this helps
 
Kalyana Sundaram
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean it !!!

 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"LLL LLL",

Welcome to JavaRanch. We don't have many rules here, but we do have a naming convention which we try to strictly enforce. I believe another user has already pointed you to this document. Please re-read the naming convention and edit your display name in order to comply.

Thanks and we look forward to seeing you around the Ranch.
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in your action class, you commented everything out and forward to 'failure' forward name which is mapped to the 'failure.jsp'. what's in there? i am betting a blank page.

also, when you decide to uncomment your codes, change the signature 'ActionForm action' to 'ActionForm form'. either the example is really bad or you're not following the example closely enough.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by alan do:
in your action class, you commented everything out and forward to 'failure' forward name which is mapped to the 'failure.jsp'. what's in there? i am betting a blank page.



... oooor the failure forward is not defined in the ActionMapping (struts-config entry)
 
Betsy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
failure.jsp

<html>
<body>
failure !!
Registration failure!!
</body>
</html>

failure.jsp is as above.
it doesnot get displayed.
Next as kalyana sundaram had pointed out, i have gone thru the tablibs also.
I dont find any difference in that.
 
Betsy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried by changing the uri also. I didnt help.

<%@taglib uri="/tags/struts-html" prefix="forms"%>
<forms:form action="/register">
[ July 12, 2005: Message edited by: Betsy ]
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

According to java naming conventions, all the property names should start with lower letter and the firstletter of the words following should start with capital letter.

Try changing username to userName, password1 to passWord1 and password2 to passWord2 in your jsp and ActionForm and don't forget to modify getter and setter methods too.

I hope it helps you.
[ July 13, 2005: Message edited by: cendy nguvy ]
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Betsy",

Thanks for changing your name, but I'm afraid it still doesn't comply. Please re-read the naming convention. Specifically you must have a valid first name and a valid last name. You should be able to quickly notice that there are no users on this site with one single name. Thank you.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by LLL LLL:
failure.jsp

<html>
<body>
failure !!
Registration failure!!
</body>
</html>

failure.jsp is as above.
it doesnot get displayed.
Next as kalyana sundaram had pointed out, i have gone thru the tablibs also.
I dont find any difference in that.



Again I say --
... oooor the failure forward is not defined in the ActionMapping (struts-config entry)
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by cendy nguvy:
Hi,

According to java naming conventions, all the property names should start with lower letter and the firstletter of the words following should start with capital letter.

Try changing username to userName, password1 to passWord1 and password2 to passWord2 in your jsp and ActionForm and don't forget to modify getter and setter methods too.

I hope it helps you.

[ July 13, 2005: Message edited by: cendy nguvy ]



password is one word, not two.
Also, following these "conventions" does not solve the posted problem.
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Again I say --
... oooor the failure forward is not defined in the ActionMapping (struts-config entry)



in the originally posted message shows that it is defined.
 
Betsy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Marc Peabody:


password is one word, not two.
Also, following these "conventions" does not solve the posted problem.



Yes u r right. I have tried making changes in these. But of no use.
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Betsy",

If you continue to not comply with our naming policy, I'm afraid I'll be forced to start closing your threads and have your account locked.
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by alan do:


in the originally posted message shows that it is defined.



Ah, yes it does.

The originally posted message also shows that the method used is perform()!
The perform method will never get called unless you are using an old version of Struts. Struts now calls the execute method which by default returns an ActionForward of null, which cannot be defined in the ActionMapping. Since the correct forward cannot be found in the ActionMapping, Struts gives you a blank page.

Change the name of the method from perform() to execute().

And it really is a good idea to give yourself a last name, Betsy.
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!