There's two ways you can go... One is to have an ActionForm associated with your Action, another is to use request directly.
Using request directly, you simply do this in your Action class: request.setAttribute("temp_", temp_); (that's an unusual variable name... was that underscore a typo?) ... then in your JSP, you can simply do this: String temp_ = (String)request.getAttribute("temp_"); ... and finally, wherever you want the string to appear: <%=temp%> ... so for example, you might have a complete JSP like so: <%@ page language="java" %> <% String temp_ = (String)request.getAttribute("temp_"); %> <html> <head> <title>test</title> </head> <body> My string is <%=temp_%> </body> </html> Alternatively, you can use various taglibs to get the value, but under the covers it's doing the equivalent of the above, so you might as well understand that :) The other option is to have an ActionForm (which will be called a form bean when instantiated) and associate it with your Action. For instance, you might create a class like so: import org.apache.struts.action.ActionForm; public class MyActionForm extends ActionForm { private String temp_ = ""; public void setTemp_(String temp_) { this.temp_ = temp_; } public String getTemp_() { return temp_; } } ... then, in struts-config.xml, you define the form bean before your <action-mappings> section like this: <form-beans> <form-bean name="MyActionForm" type="MyActionForm" /> </form-beans> ... and you add the following to your <action> mapping: name="MyActionForm" scope="request" validate="false" ... this is saying that whenever your /actions/register1 action is accessed, you want to have access to an instance of MyActionForm in the Action, and that further you want it associated with the request (which essentially means that a new instance of the form bean will be created for each request) and that you don't want the validate() method of the bean to be called. Now, in your Action, notice that the signature of the execute() method references a form. In your Action, you are guaranteed by Struts to have a valid form bean instance referenced by the parameter passed in. So, now in your Action you can do: String temp_ = "test"; form.setTemp_(temp_); ... and then in your JSP you get a reference to the form and call it's getter: <%@ page language="java" import="MyActionForm" %> <% MyActionForm form = (MyActionForm)request.getAttribute("MyActionForm"); %> <html> <head> <title>test</title> </head> <body> My string is <%=form.getTemp_()%> </body> </html> ... or again, use one taglib or another to access the bean, whether it's the Struts taglibs, JSTL, or whatever else you prefer. Again though, what's happening underneath it all is equivalent to the above, so better to know about it before abstracting it away with the taglibs. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com On Fri, February 11, 2005 10:52 am, Larry Meadors said: > Use request.setAttribute(name, value) to put the data into request scope, then from your jsp, use jstl to get to the value: > > --- > // in your action class: > request.setAttribute("foo", "My String"); > --- > > --- > <!-- in your jsp: --> > <c:out value="${foo}" /> > --- > > Google for a JSTL tutorial - there are a pile of them. > > Larry > > On Fri, 11 Feb 2005 16:48:24 +0100, pck <[EMAIL PROTECTED]> wrote: >> Hello, >> >> I'm very begginer in java and struts so please forgive me for this question... >> >> I've got servlet: >> >> <action-mappings> >> <action path="/actions/register1" >> type="RegisterAction1"> >> <forward name="success" >> path="/WEB-INF/results/result1success.jsp"/> >> <forward name="filed - bad xml recived" >> path="/WEB-INF/results/result1failedxmlbad.jsp"/> >> <forward name="SQL - insert problem" >> path="/WEB-INF/results/result1sqlproblem.jsp"/> >> </action> >> </action-mappings> >> >> When I visit with my IE/Firefox /actions/register1.do it is evoked. In this servlet I do some caluculations and then i want to show this on the screen. >> >> For example my variable look like: >> String temp_ = "test"; >> >> And then do: return(mapping.findForward("success")); >> >> So result1success.jsp must display this temp_ on the screen. >> >> How to do it? >> >> TIA! >> pck. >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]