MR AND
MR AND

Reputation: 406

getting a value from a variable in jsp's input type

In my jsp i have a variable

String str = "Get_Name";

What can i do to have my variable(str) directly accessed in the input type shown below? By this I want to see the form auto filled with the the variable I have instead of me filling it.

<input id="vendorName" name="vendorName" type="text" class="txtsmall2" />

Upvotes: 1

Views: 1261

Answers (1)

Shrinivas Shukla
Shrinivas Shukla

Reputation: 4453

ANSWER ALSO CONTAINS SOLUTION FOR PROBLEM DISCUSSED IN COMMENTS.

Do this.

<%
    long val = 2;   //can be anything.
    if(val > 1) {
%>
<input id="vendorName" name="vendorName" type="text" class="txtsmall2" value="<%=str%>"/>
<%
    else {
%>
<input id="vendorName" name="vendorName" type="text" class="txtsmall2" />
<%
    }
%>

<%=str%> is called as expression tag.

Upvotes: 1

Related Questions