|
Hello room,
I am having one bean DataAccessBean.From the
main.jsp I called the Search_servlet .There I am getting the search parameter
and created an instance of DataAccessBean connected to the database and populate
some info on bean variable.
After calling the servlet from main.jsp I called
search.jsp to display the bean property.But its not displaying.can anybody help
me.....
Daison
main.jsp
<html>
<head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000"> <CENTER>
<FORM method=get >
<p><font color="#FF0080"><font
size=+3>
Vendor Lookup :</font></font><font
color="#FF0080"><font
size=+3></font></font>
<input type =text name =search> <p> <BR> </CENTER> <CENTER> <TABLE> <TR> <TD><INPUT TYPE=SUBMIT name =Add value
=Add></TD>
<TD><INPUT TYPE=SUBMIT name =submit value =submit></TD> <TD><INPUT TYPE=SUBMIT name =Delete value =Delete></TD> </TR>
</TABLE> <% if(request.getParameter("search")!=null){ %> <h1>results</h1>
<SERVLET NAME = "Search_servlet1" code =
"Search_servlet" ></SERVLET>
<h1>results1</h1>
<%}
else { %> <hr ALIGN=CENTER SIZE=1
WIDTH="750">
<p> <CENTER><img SRC="customer.jpg" height=254 width=432> <p> </CENTER> <%
} %> </FORM>
</body> </html> search.jsp
<h1>in search.jsp </h1>
<bean name="searchBean" type="DataAccesBean" introspect="yes" create = "yes" scope = "session"> </bean> <P><B><CENTER>Search Results</B></CENTER> <H1> <H1> <INSERT BEAN ="searchBean" PROPERTY
="VendorName"></INSERT>
Here its not diaplaying
the VendorName Please Help me.
</h1>
</h1> Search_servlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*; import java.sql.*; import java.util.*; import test1.*; public class Search_servlet1 extends
HttpServlet
{ public void init(ServletConfig config) throws ServletException{ super.init(config); }
public void doGet
(
HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { PrintWriter out; String title = "Database connectivity test on NOVA"; int Vendorid=0;
response.setContentType("text/html");
// then write the data of the
response
out = response.getWriter(); DataAccessBean data = new
DataAccessBean();
Vendorid =
Integer.parseInt(request.getParameter("search"));
data.getDBConnection(Vendorid); data.populateVendor();
response.sendRedirect("/IBMWebAS/samples/vendor_search/search.jsp");
out.close();
} }// DataAccessBaen.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*; import java.sql.*; import java.util.*; /** * This is a simple example of an HTTP Servlet. It responds to the GET * and HEAD methods of the HTTP protocol. */ public class DataAccessBean implements Serializable { /** * Handle the GET and HEAD methods by building a simple web page. * HEAD is just like GET, except that the server returns only the * headers (including content length) not the body we write. */ Statement stmt;
ResultSet rs=null; int VendorId=0; String VendorName=""; public void dbConnect(){
System.out.println("HI"); } public String getColumn(String
columnName)
{ String tempColumn=""; try { tempColumn = rs.getString(columnName); }catch(SQLException e) { System.out.println("Unable to retrieve the column ->" + e); } return tempColumn;
}
public void
moveCursor()
{ try { rs.next(); }catch(SQLException e) { System.out.println("Unable to move to next row ->" + e); } }
public void
populateVendor()
{ try { setVendorId(getColumn("vendor_id")); setVendorName(getColumn("vendor_name")); }catch(Exception e) { System.out.println("Unable to Populate info ->" + e); } } public void setVendorId(String
Id)
{ VendorId =Integer.parseInt(Id); } public void setVendorName(String
Name)
{ VendorName =Name; } public int getVendorId()
{ return VendorId; }\ public String getVendorName()
{ return VendorName; } }//
|
- Bean in JSP Daison Jose
- Bean in JSP Scott Kumamoto
- How to Post Data IN JSP Pratik
- Re: How to Post Data IN JSP Kumail Rizvi
- Re: How to Post Data IN JSP Dinesh Venkatraman
- Re: How to Post Data IN JSP Robert Nicholson
- Re: How to Post Data IN JSP Pratik
- Re: Bean in JSP Kumail Rizvi
- Re: Bean in JSP LISTS
- Re: Bean in JSP Vijaya Shankar
- BEAN in JSP Chandhan Rangarajan
