doubt in jsp and struts

in first jsp i am entering one address

and i am putting that address in request scope in action class

i am getting that addres in the next jsp page.

if i put directly in textarea in that secondpage it is comming.

but i am getting value through javascript

it is not comming.

i send the code with this

jsp page

<html:checkbox property="sameasshippingaddress" value="same as shipping address" onclick="setBillingAddress(this)"/>Same As Shipping Address

<table border="0" width="48%" id="table3">

<tr>

<td width="134">Billing Address</td>

<td><html:textarea property="billingaddress"/></td>

javascript:

<%

String billingAddress = (String)request.getAttribute("addd");

pageContext.setAttribute("billingAddress ", billingAddress );

%>

function setBillingAddress(billadd)

{

if(billadd.checked)

{

billadd.form.billingaddress.disabled = true;

billadd.form.billingaddress.value = "<%=billingAddress%>";

}

else

{

billadd.form.billingaddress.disabled = false;

billadd.form.billingaddress.value = "";

}

}

please help me

[1268 byte] By [kathir226a] at [2007-10-2 5:14:07]
# 1

javascript:

<%

String billingAddress = (String)request.getAttribute("addd");

pageContext.setAttribute("billingAddress ", billingAddress );

%>

function setBillingAddress(billadd)

{

if(billadd.checked)

{

billadd.form.billingaddress.disabled = true;

billadd.form.billingaddress.value = "<%=billingAddress%>";

I think you need to do like this:

javascript:

<%

String billingAddress = (String)request.getAttribute("addd");

pageContext.setAttribute("billingAddress ", billingAddress );

%>

function setBillingAddress(billadd)

{

if(billadd.checked)

{

billadd.form.billingaddress.disabled = true;

var billingAddress = <%=request.getAttribute("addd")%>

billadd.form.billingaddress.value = billingAddress

The issue with your code is that

String billingAddress = (String)request.getAttribute("addd");

is declared in JSP (service method I think), it's not declared in your javascript.

BTW, the otherway around, ie. trying to pass Javascript variable value to JSP variable is impossible directly. You have to use session or a hidden form variable which later can be retrieved be calling 'getParameter()' method in the action handler jsp or servlet.

Hope this is what you want.

X.Chen

chasera at 2007-7-16 1:16:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...