/    Sign up×
Community /Pin to ProfileBookmark

useBean setProperty

Hi everyone,

Q1. How do I set a value I received from an input field in an HTML form, into a useBean setMethod within my javascript function findCustomer()

Note : I am able to store a literal value.

Q2. How do I retrieve the useBean Object in my controller servlet.

eg

main.jsp
———-

<jsp:useBean id=”srchCustomer” class=”com.ap.SrchCustomer” scope=”request” />
.
.
.
.
<script language=”JavaScript”>
function findCustomer()
{
alert(“document.frmTab.srchName.value : ” + document.frmTab.srchName.value);

<%srchCustomer.setSrchName(????????); %>

}

</script>
.
.
.
.
<input type=”text” name=”srchName” size=”40″ maxlength=”50″/>
.
.
.

SrchCustomer.java
———————

package com.ap;

import java.io.*;

public class SrchCustomer implements Serializable
{
String name=null;

public SrchCustomer() {}
public void setSrchName(String cName) {name = cName;}
}

Thanks in advance.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63May 05.2003 — [i]Originally posted by lakshman [/i]

[B].......... <%srchCustomer.setSrchName(????????); %>

}

......... [/B]
[/QUOTE]


You can not do that,reason being Javascript runs on client side that is in the scope of a browser window,where as your jsp code runs on the webserver.

The only way to forward information from client ot serer is using HTTP Request object.

What you need to do is submit theinformation to the jsp page and in the jsp code get the info frm request object using

String value = request.getParameter("FromFieldName")

//once this is done then

srchCustomer.setSrchName(value);

for jsp questions though,best place will be

http://forum.java.sun.com/forum.jsp?forum=45
Copy linkTweet thisAlerts:
@lakshmanauthorMay 05.2003 — Hi khalid,

Thanks a million. You are champ.

So much to learn and so little time....!!!
Copy linkTweet thisAlerts:
@khalidali63May 05.2003 — ?

You are welcome,

Glad to be of any help
×

Success!

Help @lakshman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...