- This topic has 14 replies, 4 voices, and was last updated 19 years, 11 months ago by john.
-
AuthorPosts
-
duraaceMemberI’ve been trying for several days to get the following framework working for a project. The flow is straightforward, but I’m stuck at one point:
login (name, pwd) -> action -> returns a form, with some fields that can be edited-> update/subitted to another action handler returning a success/failure page.
I’ve got the first action return working, but not the subsequent one on the original returned form/values. Could anyone provide me with do list/program structure using JSP’s, Action servlets, etc.?
BTW Years of client side and server side Java, but no JSP/strut experience. This is driving me crazy. The tutorials don’t appear to cover the above scenerio.
Riyad KallaMemberMoving to OT > Soft Dev (not ME related, its a Struts question)
duraace,
I suggest posted a zip of your project or code snippets (assuming its short enough) so people can help.
Nabil SuleimanParticipantso you get the login done fine, then you want to return some html form (fields to be edited ?) and once that’s submitted you forward to success/failure page ?
Riyad KallaMemberI’ll shoot in the dark here and guess you aren’t sticking your forms in the right scope, or are forgetting to repopulate the form values and you have it in the request, so they are trashed after your ‘update’ post…
duraaceMemberIt was suggested I .zip the project and upload here. It’s not obvious to me how to do that. Also, to reiterate, I’m returning values via a .jsp on a login action. I what that .jsp via a submit button (got that) to tigger an action so I can process that edited values in a Java class.
Riyad KallaMemberduraace,
I wasn’t asking you to post the ZIP file here, but post it online so people can download it and try and help you. We don’t support posting of attachments in these forums.
duraaceMemberI don’t have a site to host the file, so I’ll take another approach. Can you list the steps using MyEclipse to produce the following program structure. I have onle part working, but I may have painted myself into a corner by doing it.
login.jsp invoking a Java Action class->returns editable values to a result.jsp->which in turn invokes another Java Action to process those same fields. I don’t have the latter step working.
<MyEclips Steps go here> Many thanks.
Riyad KallaMemberPaste your source for struts-config.xml, result.jsp, the Struts Action it calls and the last success page for me to look at.
duraaceMemberFollowing 2 struts action classes defined in project
com.eTravel.struts.action.LoginAction – is invoked by login.jsp submit
com.eTravel.struts.action.submitCedentialsAction – not being called from login->dispCredentiials.jsp (login-> results)struts-config.xml
<!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 />
<form-beans >
<form-bean name=”loginForm” type=”com.eTravel.struts.form.LoginForm” />
<form-bean name=”submitCredentialsForm” type=”com.eTravel.struts.form.SubmitCredentialsForm” /></form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute=”loginForm”
input=”/form/login.jsp”
name=”loginForm”
path=”/login”
scope=”request”
type=”com.eTravel.struts.action.LoginAction” >
<forward name=”credentials” path=”/form/dispCredentials.jsp” />
</action>
<action
attribute=”submitCredentialsForm”
input=”/form/dispCredentials.jsp”
name=”submitCredentialsForm”
path=”/submitCredentials”
scope=”request”
type=”com.eTravel.struts.action.SubmitCredentials” /></action-mappings>
<controller bufferSize=”4096″ debug=”0″ />
<message-resources parameter=”com.eTravel.struts.ApplicationResources” />
</struts-config>dispCredentials.jsp (the result from login.jsp)
<%@ page language=”java” import=”java.util.*” %>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-bean” prefix=”bean”%>
<%@ taglib uri=”http://jakarta.apache.org/struts/tags-html” prefix=”html”%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+”://”+request.getServerName()+”:”+request.getServerPort()+path+”/”;
%><!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>JSP for submitCredentials form</title>
<base href=”<%=basePath%>”><meta http-equiv=”pragma” content=”no-cache”>
<meta http-equiv=”cache-control” content=”no-cache”>
<meta http-equiv=”expires” content=”0″>
<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>
<meta http-equiv=”description” content=”credentials submission page”></head>
<body>
<html:form action=”/login”>e-mail address: <html:text property=”emplID”/> Is this correct?/br
<html:submit/><html:cancel/>
<!–comment
result: <%=session.getAttribute(“emplID”)%> Is this right?
–></html:form>
</body>
</html>Can you please post all the information we request in the [URL=http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-393.html]Posting Guidelines[/URL] thread at the top of this forum? That will give us some context so that we can determine if this is an installation issue, a configuration problem, or a bug. Thanks.
Riyad KallaMemberDo me a favor, change your “scope=request” attributes for both your actions to “Scope=session” just to see if that is the issue. Otherwise make sure your param names are correct.
duraaceMemberWin2k
Eclips 3.0.1 build 200409161125
– Was Eclipse freshly installed for MyEclipse? – No
– If not, was it upgraded to its current version using the update manager? – Yes
What MyEclipse version are you using? (Help > About Eclipse Platform > Features)
3.8.2 200408201200-3.82What JDK version are you using to run Eclipse? (java -version)
J2SDK1.4.2_05
What JDK version are you using to launch your application server?
sameWhat application server are you using?
JBoss 1.4.0
Nabil SuleimanParticipantjboss 1.4 ?
duraaceMember@support-rkalla wrote:
Do me a favor, change your “scope=request” attributes for both your actions to “Scope=session” just to see if that is the issue. Otherwise make sure your param names are correct.
Before I do that, you need to know that the current dispCredentials, being invoked by the LoginAction is not coded correctly. It’s a syntax problem at this point. I don’t how to code retrieve values in a form from LoginAction. After that, the problem is “how” to invoke the submitCredentialsAction with the same values returned from the loginAction.
Riyad KallaMemberduraace,
I think it would be best pickup a copy of Struts in Action, its an excellent book to get you started and I’m tied up with too much work to continue helping today with this.
johnMemberNot sure if this is the whole issue, but this is a problem.
Currently in your file dispCredentials.jsp, you have this:
<pre> <html:form action=”/login”></pre>
That will cause the form to submit to your login action, which, if I understand corrently, is not what you want. (The user has already logged in by the time (s)he’s on this page.) To submit to your SubmitCredentials action, use:
<pre> <html:form action=”/submitCredentials”></pre>
Also double-check the class name in the type attribute of your SubmitCredentials action mapping. It’s not the same as the class name you have at the beginning of your message. -
AuthorPosts