<%@page language="java"%> <html> <title> Success </title> <body> <%!String s;%> <% s=(String)request.getAttribute("&noc");// i did like this but it always print null %> <form> The value =<input type=text name="t" value=<%=s%>/>!!!<p><a href="add.jsp"> try someother???</a></p> </form> </body> </html>
I am not sure about your existing code...it seems like it might work. What I would do is to add the property noc to my form, update that property in my action and not mess with setting individual values on the request. This approach would definitely simplify your JSP code.
I am not sure about the default values. - if redirect=true, index page to controller first request and controller to view is second request. second request is from the browser, so you might need scope=session. - if redirect=false, the same request will be forwarded from controlle to view. so scope=request will work here.
Joined: Feb 08, 2006
I have no idea how that change would have fixed your problem. The default for redirect is false if it is not specified so I don't see where your change would make a difference. Were there other changes that you made?
and its working fine now?? But m clueless....... any help regarding the flow(links are welcome)...!!!
Joined: Feb 08, 2006
Comparing your two code postings I see three changes 1) added redirect="false" - it does not seem like this should matter 2) added a closing / to your input tag - this should not matter 3) changed attribute from "&noc" to "noc" - hmmm...would this make a difference?
oh well...I am glad you got it working.
Joined: Oct 11, 2006
I also feel the same Brent. But i like to knoe the flow... any help!!
looks like the issue was with the &noc. I guess you are asking about the code flow.
1. when the user input the value , the values are get assigned to your bean (here addform). 2. now when the user submit the data for futher process, the control comes to your action(via Actionservlet, which is internal to struts, the user don't have to wrry abt this class & struts-config.xml) where you will get the input values from the your form (addform)
3. Now you are assigning the final value, noc to the request attribute named "noc". You can give any name in the first parameter.
4. and then you are telling the strut-config.xml that take me to "success" page, by mentioning return mapping.findForward("success");
5. now in struts config, you have mapping for a "success" to success.jsp. & you get the result page, where you are retriving the noc value from request attribute.
Hope this helps.
subject: How to Pass Parameter from .java to struts-config.xml to .jsp