Steve Bills

Greenhorn
+ Follow
since Feb 19, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steve Bills

Please find my struts-config.xml file below

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>

<!-- Data Sources -->
<data-sources>
</data-sources>

<!-- Form Beans -->
<form-beans>
<form-bean name="myForm" type="com.fms.clientweb.resources.LoginForm"/>
</form-beans>

<!-- Global Exceptions -->
<global-exceptions>
</global-exceptions>

<!-- Global Forwards -->
<global-forwards>
<forward name="homePage" path="/homePage.do" />
</global-forwards>

<!-- Action Mappings -->
<action-mappings>
<action path="/homePage" name="myForm" type="org.apache.struts.actions.ForwardAction" parameter=".logon" />
<action path="/logon" type="com.fms.clientweb.actions.LogonAction">
<forward name="success" path=".logonSuccess"></forward>
<forward name="failure" path=".logon"></forward>
</action>
</action-mappings>

<!-- Message Resources -->
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"></controller>
<message-resources parameter="com.fms.clientweb.resources.ApplicationResources"/>
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/>
<set-property property="moduleAware" value="true" />
</plug-in>

</struts-config>


My Action Class:

package com.fms.clientweb.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.fms.clientweb.forms.LoginForm;

import bd.FMSBusinessDelegate;

/**
* @version 1.0
* @author
*/
public class LogonAction extends Action {

/**
* Constructor
*/
public LogonAction() {
super();
}

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("Entered the Execute menthod in logon action" );

ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward();

try {
LoginForm loginForm = (LoginForm) form;
String name = loginForm.getName();
String pass= loginForm.getPassword();

/* String name = request.getParameter("uname");
String pass = request.getParameter("pwd");*/
System.out.println("the value of the userid is" +name);
System.out.println("the value of the password is" +pass);
// test call to the database
FMSBusinessDelegate bd = new FMSBusinessDelegate();
bd.testDb();
//LDAP Authentication
if ( bd.ldapAuthentication(name,pass)) {
forward = mapping.findForward("success");
} else {
forward = mapping.findForward("failure");

}
} catch (Exception e) {
// Report the error using the appropriate name and ID.
errors.add("name", new ActionError("id"));
forward = mapping.findForward("failure");
}

// If a message is required, save the specified key(s)
// into the request for use by the <struts:errors> tag.

if (!errors.isEmpty()) {
saveErrors(request, errors);
}
System.out.println("end of execute method in actionform class" );
return (forward);

}
}


My Jsp:

<%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>

<h1 class="page_title">File Management System</h1>
<html:form action="logon.do">
<table>
<tr>
<td>
<h3 >Sign in</h3>
</td>
<td>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<h3 >User ID:</h3>
</td>
<td>
<h3><html:text styleClass="text" property="name" /> </h3>
</td>
</tr>
<tr>
<td></td>
<td>
<h3 >Password:</h3>
</td>
<td>
<h3><html:text styleClass="password" property="password"/></h3>
</td>
</tr>
<br></br>
<tr>
<td></td>
<td></td>
<td ><div style="display:none" name="myspan"><font color="red">Please enter the valid username and password</font></div></td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<h3><html:submit property="Submit" value="Submit" /></h3>
</td>
</tr>
</table>
</html:form>
14 years ago
Hello,

I am kind of new to Struts framework in Java.
I tried a sample application with a login page and an action class it worked out very well.

But when I try implementing the ActionForm, where we have all getter and setter methods for the form properties I had to do do a change in my login jsp as i needed property tags to pass my values to that Action form class but when i started using <html:text property=""> and <html:form> tags I am getting an error saying
ServletException in:/pages/logon.jsp] Cannot retrieve definition for form bean null'


this is the error stack trace:

avax.servlet.jsp.JspException: Cannot retrieve definition for form bean null
at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:831)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
at com.ibm._jsp._logon._jspx_meth_html_form_0(_logon.java:149)
at com.ibm._jsp._logon._jspService(_logon.java:70)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.include(WebAppRequestDispatcher.java:639)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:1034)
at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:484)
at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137)
at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177)
at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756)
at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881)
at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473)
at com.ibm._jsp._template._jspx_meth_tiles_insert_2(_template.java:150)
at com.ibm._jsp._template._jspx_meth_html_html_0(_template.java:200)
at com.ibm._jsp._template._jspService(_template.java:74)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:254)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:309)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:518)
at org.apache.struts.taglib.logic.ForwardTag.doEndTag(ForwardTag.java:170)
at com.ibm._jsp._index._jspx_meth_logic_forward_0(_index.java:92)
at com.ibm._jsp._index._jspService(_index.java:66)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:501)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:205)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:321)
at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:555)
at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3252)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:264)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1439)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:112)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:263)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)


My JSP Page:


<html:form action="logon.do">
<table>
<tr>
<td>
<h3 >Sign in</h3>
</td>
<td>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<h3 >User ID:</h3>
</td>
<td>
<h3><html:text styleClass="text" property="name" /> </h3>
</td>
</tr>
<tr>
<td></td>
<td>
<h3 >Password:</h3>
</td>
<td>
<h3><html:text styleClass="password" property="password"/></h3>
</td>
</tr>
<br></br>
<tr>
<td></td>
<td></td>
<td ><div style="display:none" name="myspan"><font color="red">Please enter the valid username and password</font></div></td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<h3><html:submit property="Submit" value="Submit" /></h3>
</td>
</tr>
</table>
</html:form>


My ActionForm class:


public class LoginForm extends ActionForm {
private String name=null;
private String password=null;

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
password = password;
}
/**
* Reset all properties to their default values.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.name=null;
this.password=null;

}

public ActionErrors validate(
ActionMapping mapping, HttpServletRequest request ) {
ActionErrors errors = new ActionErrors();

if( getName() == null || getName().length() < 1 ) {
errors.add("name",new ActionMessage("error.name.required"));
}
if( getPassword() == null || getPassword().length() < 1 ) {
errors.add("address",new ActionMessage("error.address.required"));
}


return errors;
}



}




Your help will be really appreciated






14 years ago
Thank you so much. It worked beautifully!
14 years ago
i have my development structure set up as follows...

BeerSelect is my project folder. Below that are five folders... etc lib src classes web. in my src folder the structure is src->com->example ...example contains
two folders one called web and and the other is model. My classes folder has a similar structure classes->com->example with example again breaking into
two subfolders called web and model.

My BeerSelect.java file is located in the src/com/example/web/BeerSelect.java - which is how the book has it structured. My BeerExpert.class is located in classes/com/example/model/BeerExpert.class. So when I entered this on the command line...

javac -classpath /Users/bert/Applications2/tomcat/common/lib/servlet-api.jar:. classes src/com/example/model/BeerExpert.java

is classes pointing towards the classes/com/example/model/BeerExpert.class? Should it pointing somewhere else?

once again, thank you!
14 years ago
Hi,

Thank you for your replay. hmmm, you were correct about command line arg. It should of read....

javac -classpath /Library/Tomcat/Home/lib/servlet-api.jar:. classes src/com/example/web/BeerSelect.java

the book has a javac -classpath /Users/bert/Applications2/tomcat/common/lib/servlet-api.jar:. classes src/com/example/web/BeerSelect.java

the book's author has a different location for his tomcat. He is also using tomcat 5.5 and Java 5. I'm using Tomcat 6 and Java 6. My class is correct, if I do this
command line arg...

javac -classpath /Users/bert/Applications2/tomcat/common/lib/servlet-api.jar:. classes src/com/example/model/BeerExpert.java


...that file will compile flawlessly. any ideas? The BeerSelect.java still cannot find the import com.example.model.*;

Thank you




14 years ago
Thank you very for looking at my question...and yes, I have seen this question asked before here.
This is the beloved "Beer" program from Head First Java second edition. I seen some windows solutions...
however, I'm using MacOS X 10.6 via the command line and haven't found a solution that fits what I'm
having trouble with.

...here's my prompt... javac /Library/Tomcat/Home/lib/servlet-api.jar:. classes src/com/example/web/BeerSelect.java


and here are the error codes...

src/com/example/web/BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
error: Class names, 'classes', are only accepted if annotation processing is explicitly requested
src/com/example/web/BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
src/com/example/web/BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();


...the problem is with the import com.example.model.*; I checked my directory and they are
set up properly. I've gone through the code several times and cannot see any incorrect syntax.

any ideas on the fix for this?

Thanks!
14 years ago