wood burning stoves 2.0*
The moose likes Struts and the fly likes what does .do file extension indicate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "what does .do file extension indicate" Watch "what does .do file extension indicate" New topic
Author

what does .do file extension indicate

Suman Dass
Greenhorn

Joined: Feb 20, 2002
Posts: 28
what does .do file extension indicate; e.g. login.do
Jose Velarde
Ranch Hand

Joined: Sep 11, 2002
Posts: 78
It's just a servlet mapping defined in the deployment descriptor (web.xml).

The container will pass to the Action Servlet any request that matches the pattern. However, any valid prefix or extension can be used. Developers just use .do since it's more popular.
[ November 16, 2002: Message edited by: Jose Velarde ]
Suman Dass
Greenhorn

Joined: Feb 20, 2002
Posts: 28
thnx jose! actually i was trying to run the progarm given in javaranch's struts topic. i'm using weblogic 7.0. while LoginView.jsp is working, on submission, it calls login.do after which it goes blank, i.e. ActionServlet doesnt seem to get called. The directory structure of Weblogic is slightly different than Tomcat.
Jose Velarde
Ranch Hand

Joined: Sep 11, 2002
Posts: 78
Check the struts-config.xml. You probably are missing some entries there.
Suman Dass
Greenhorn

Joined: Feb 20, 2002
Posts: 28
Hi!
unfortunately i still couldnt resolve the problem.....the login.do returns a blank page...seems ActionServlet is unable to proceed. Here's my directory structure (weblogic 7.0) and the source codes (more or less same as March article). Pl help.

examplesWebApp
|_WEB-INF
||_______classes
||_______lib |___test
|struts-config.xml |__struts
|web.xml LoginAction.class
| LoginBean.class
MainMenu.jsp LoginForm.class
LoginView.jsp MessageResource.props

The files are as under:
<!-- LoginView.jsp -->
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts.tld" prefix="struts" %>
<HTML>
<HEAD><TITLE><struts:message key="title.login" /></TITLE></HEAD>
<BODY>
<struts:message key="heading.login" />
<html:errors />
<html:form action="/login">
<p>
<struts:message key="label.userId" />:
<html:text property="userId" size="10" />
<br>
<struts:message key="label.passWord" />:
<html assword property="passWord" size="10" />
<br><br>
<html:submit>
<bean:message key="button.submit" />
</html:submit>
</html:form>
</BODY>
</HTML>
******************************************************
File:struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
<struts-config>
<!-- ========== Form Bean Definitions ============ -->
<form-beans>
<form-bean name="login" type="test.struts.LoginForm" />
</form-beans>

<!-- ========== Global Forward Definitions ========= -->
<global-forwards>
</global-forwards>

<!-- ========== Action Mapping Definitions ======== -->
<action-mappings>
<action
path="/login"
type="test.struts.LoginAction"
scope="request"
name="login"
input="LoginView.jsp"
validate="true">
<forward name="valid" path="MainMenu.jsp" redirect="true"/>
<forward name="invalid" path="LoginView.jsp" redirect="true"/>
</action>
</action-mappings>
</struts-config>
**********************************************
<!-- MainMenu.jsp -->
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts.tld" prefix="struts" %>
<jsp:useBean id="LoginBean" scope="request" class="test.struts.LoginBean" />
<HTML>
<HEAD><TITLE><struts:message key="title.mainmenu" /></TITLE></HEAD>
<BODY>
<struts:message key="heading.mainmenu" />
<p>
<struts:message key="label.userType" />:
<b><jsp:getProperty name="LoginBean" property="userType" /></b><br>
</BODY>
</HTML>
**********************************************
File: web.xml
<web-app>
<display-name>Examples Web Application</display-name>
<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>test.struts.MessageResources</param-value>
</init-param>
<init-param>
<param-name>mapping</param-name>
<param-value>org.apache.struts.action.RequestActionMapping</param-value>
</init-param>
<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>
<load-on-startup>2</load-on-startup>
</servlet>

<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
</web-app>
*************************************************
package test.struts;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginAction extends Action {
public LoginAction() {}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException{
LoginBean lb = new LoginBean();
request.setAttribute("LoginBean", lb);
lb.setParameters(request);
ActionErrors ae = lb.validate();
request.setAttribute(Action.ERROR_KEY, ae);
if (ae == null || ae.size() == 0) {
System.out.println("after LoginAction");
return mapping.findForward("valid");
} else {
return mapping.findForward("invalid");
}
}
}
*****************************
package test.struts;
import org.apache.struts.action.*;
import javax.servlet.http.*;
public class LoginForm extends ActionForm {
String userId, passWord;
public void setUserId(String userId) {
this.userId = userId;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
public String getUserId() {
return userId;
}
public String getPassWord() {
return passWord;
}
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors ae = new ActionErrors();
if (userId == null || userId.equals("")) {
ae.add("userId", new ActionError("error.no.userId"));
}
if (passWord == null || passWord.equals("")) {
ae.add("passWord", new ActionError("error.no.passWord"));
}
return ae;
}
}
******************************************
package test.struts;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class LoginBean {
String userType, userId ,passWord;
public LoginBean() {}
public void setParameters(HttpServletRequest request) {
String userId = request.getParameter("userId");
String passWord = request.getParameter("passWord");
}
public ActionErrors validate() {
if (!userId.equals(passWord)) {
ActionErrors ae = new ActionErrors();
ae.add("userId", new ActionError("error.invalid.login"));
return ae;
}
if (userId.equals("admin")) {
userType = "Adminstrator";
} else
if (userId.equals("user")) {
userType = "User";
} else {
ActionErrors ae = new ActionErrors();
ae.add("userId", new ActionError("error.invalid.login"));
return ae;
}
return null;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
}
*****************************************
File: MessageResources.properties
title.login=Login
button.submit=Send for Verification
error.no.userId=<li>User ID is a required field</li>
error.no.passWord=<li>Password is a required field</li>
error.invalid.login=<li>The User ID and/or Password are invalid. Please try again.</li>
errors.footer=</ul><hr>
errors.header=<h3><font color="red">Validation Error</font></h3>You must correct the following error(s) before proceeding:<ul>
label.userId=User ID
label.passWord=Password
heading.login=<H2>Enter your user information</H2>
heading.mainmenu=<H1>Welcome!</H1>
label.userType=<H2>You are authorized to use this system as a</H2>
title.mainmenu=Title
Suman Dass
Greenhorn

Joined: Feb 20, 2002
Posts: 28
my directory structure once again:
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
Hi Suman,
to try to work out what error you are getting, do some or all of the following:
- check the weblogic log files for exceptions
- put logging to the console in your action's perform or execute
- put logging in your form bean's reset() and validate() methods
- log which forward you return from your perform/execute() in the action
Also I don't recognise the "redirect" attribute on the forwards you declare in your action mapping for the login.do - do you know what it does? Otherwise get rid of it for now.
This should get you more info that should point to what you need to do.


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Alexander Klimuk
Greenhorn

Joined: Nov 18, 2002
Posts: 1
Why have you removed slashes?
E.g. you have following line in Action Mapping:
<forward name="valid" path="MainMenu.jsp" redirect="true"/>
Normally, path should be specified like path="/MainMenu.jsp"
The same about "LoginView.jsp".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what does .do file extension indicate
 
Similar Threads
All about action servlet
how to read/open a file lec2.ps ?
.do files in struts
Database read problem
Downloading only after prompt...