How to write status in JSP (two implementations) _jsp programming

Source: Internet
Author: User
Write the project today, encountered this problem, because the framework is 2005, JSP can not store tags, can only have Java code to write, the following is the example I wrote two examples can be successful!
Also wrote the use of the label in the JSP notation

writing Java code in a JSP
Method One:
State:
Copy Code code as follows:

<select name= "states" >
<option value= "0" <%= "0". Equalsignorecase (states)? " Selected ":" "%>> available </option>
<option value= "1" <%= "1". Equalsignorecase (states)? " Selected ":" "%>> not available </option>
</select>

Method Two:
Copy Code code as follows:

<tr>
<TD align= "Right" bgcolor= "f0f8ff" class= "TITLE-TD1" > Status </td>
<TD colspan= "2" class= "TITLE-TD2" >
<select name= "status" id= "status" >
<option value= "" >== Please choose ==</option>
<option value= "0" <%if (Log.getstatus (). Equals ("0")) {%> selected <%}%>> deactivate </option>
<option value= "1" <%if (Log.getstatus (). Equals ("1")) {%> selected <%}%>> normal </option>
</select>
</td>
</tr>

referencing labels in a JSP
Copy Code code as follows:

<%@ taglib prefix= "C" uri= "Http://java.sun.com/jsp/jstl/core"%>
<tr>
<td height= "align= right" class= "TD3" > class   :</td>
<td align= "left "class=" Td4 ">
<select name=" state "class=" Search_input "onfocus=" This.si=this.selectedindex; "onchange=" this.selectedindex=this.si; " >
<option value= "" >== Please select ==</option>
<option value= "neighbourhood" <c:if test= "${smsname.state==" Neighborhood '} ' >selected</c:if> > Neighborhood Committee </option>
<option value= "community" <c:if test= "${smsname.state==" Community '} ' >selected</c:if>> community </option>
</select>
</td>
</tr>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.