I want to set the JSP variable value to the struts tag <s:set var="" value="">
,
in the following code I have to set the value of carbo
variable in <s:set name="c" value=" "/>
instead of constant value.
How can I do this?
<%! String carbo=""; %>
<%
String dish_name=(String)session.getAttribute("d");
String calories_qty=(String)session.getAttribute("a");
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/medical","root","root");
//Connection conn=dbConn.getConnection();
Statement stmt = conn.createStatement();
System.out.println("jsp dish_name="+dish_name);
System.out.println("jsp dish_name="+calories_qty);
ResultSet rs = stmt.executeQuery("Select * from calories c,dishdetail d where c.dishdetail_Id=d.id and d.dishName='"+dish_name+"' AND d.size='"+calories_qty+"' ");
while(rs.next()){
carbo=rs.getString("carbo");
//carbo=Float.parseFloat(rs.getString("carbo"));
}
System.out.println("jsp carbo:"+carbo);
}
catch(Exception e){
System.out.println("error:"+e);
}
%>
<s:set name="c" value="45" />
<p> carbo: <s:property value="#c" /></p>
<sj:progressbar cssStyle="width:20%; height:10px;" value="%{c}" onCompleteTopics="reloadfifthlist" onChangeTopics="mychangetopic"/>
I hope I understand well what you try to acheive but I'd go with
<s:set name="c" value="<%= carbo %>"/>