Hi gurus!
trying to avoid the Java code inside the JSP page, I thought about writting
getter methods in a Bean so that it returns a String containing HTML code
together with values I had to calculate. What do you think about the idea?
Thanks, Cristina.
Before: (In Calendar.jsp)
%@ page import="java.util.*" %>
<%! int hDay %>
<% Calendar ch = Calendar.getInstance();
ch.add(Calendar.DATE,7);
%>
...
<select name="seDH" >
<% for (int i=1; i<32;i++) {
if (i==hDay) { %>
<option selected><%=i %>
<% }else{ %>
<option><%=i %>
<% }} %>
</option></select>
After: (In Calendar.jsp):
<jsp:useBean id="FlyDate" class="FlyDateBean" />
...
<select name="seDH" >
<jsp:getProperty name="FlugDatum" property="hDays" />
</select>
(In FlyDateBean.java):
import java.util.*;
public class FlyDateBean {
private int hDays;
...
public String getHDays () {
String HDays = "";
for (int i=1; i<32; i++) {
if (i==this.getHDay()) {
HDays = HDays + "<option selected>"+ Integer.toString(i);
}
else {
HDays = HDays + "<option>" + Integer.toString(i);
}
}
return (HDays);
}
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets