1

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" />

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

yup did it.. is there also a way to specify condition inside those expression tags. In my case, lets assume it is a long and i would like to display it only in case when its value is greater than 1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.