Reputation: 9
I'm trying the following code in my .jsp file:
<select>
<%DBHandler db= new DBHandler();%>
<%db.init();%>
<%String[] res= db.getExpertise();%>
<% for(int i=0;i< res.length;i++){ %>
<option value="<%=res[i]%>"><%=res[i]%></option>
<%}%>
</select>
But, I don't know how to assign value in a tag using a variable in java code.
Upvotes: 0
Views: 1356
Reputation: 1078
Hope this will help your problem;
1. Directives
<%@page language="java" %>
2. Declarations
<%!
int radius = 7;
double pi = 3.1415;
%>
3. Scriptlets
<%
String id, name, dob, email, address;
id = request.getParameter("id");
name = request.getParameter("name");
dob = request.getParameter("dob");
email = request.getParameter("email");
address = request.getParameter("address");
sessionEJB.addClient(id, name, dob, email, address);
%>
4. Expressions
<%!
double radius = 7;
double pi = 22/7;
double area()
{
return pi*radius*radius;
}
%>
<html>
<body>
Area of circle is <%= area() %>
</body>
</html>
Upvotes: 2