Java Reference
In-Depth Information
this.username = username;
}
public void setPassword(String password){
this.password = password;
}
public String getUsername(){
return username;
}
public String getPassword(){
return password;
}
}
If you are working with checkboxes, where you specify the same name, but different values for each
checkbox, the only difference is that you must specify the JavaBean property as a String array.
Unfortunately, you can't get String-array values as easily. The solution in this case is to use a scriptlet,
as shown here:
<%
String[] checkBoxes = formHandler.getCheckBoxes();
for(int i=0;i< checkBoxes.length;i++){
if(i>0)out.print(",");
out.print(" "+ checkBoxes [i]);
}
%>
Using built-in JSP objects in a JavaBean
The JSP API provides access to a range of useful information about the client and about the JSP's
context through a set of built-in, implicit objects. The javax.servlet.jsp.PageContext object is the general
point of access for most of the built-in JSP objects. These objects are as follows:
 
request
 
response
 
out
 
session
 
application
 
pageContext
 
page
 
exception
request
The request object encapsulates the current request from the browser. The servlet container creates a
ServletRequest object and passes it to the servlet's service method. A ServletRequest object
provides such data as parameter name and values, attributes, and an input stream. Useful request
object methods include the following:
 
getQueryString()
 
getHeader(String headerName)
 
getCookies()
response
The ServletResponse object is designed to assist a servlet in sending a response to the client. The
servlet container creates a ServletResponse object and passes it to the servlet's service method.
Search WWH ::




Custom Search