Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

servlet and HTML text value with spaces

843841Apr 11 2006 — edited Apr 11 2006
hi,
I have a servlet that retrieve data from Oracle and put them in HTML Text boxes, to let the user make changes and save them. It is working, but if the extracted data with a space nothing will appear after the space. If I put the extracted data in a HTML table (without text box) it is working fine.
can any body have a look to may method and tell me what is wrong with it. The method is part of a big servlet.
thanks

private void Edit_Library(HttpServletRequest request, HttpServletResponse response) throws ServletException {

String libid = request.getParameter("Lib_ID");

try{ //try


con = DriverManager.getConnection(url);

Statement stmt = con.createStatement();
String query = "SELECT * FROM LIBRARY WHERE Lib_ID='"+libid+"'";


ResultSet rs = stmt.executeQuery(query);

while ( rs.next() )
{

String uni = rs.getString("UNI_NAME");
String phone = rs.getString("LIB_TEL");
String email = rs.getString("LIB_EMAIL");
String addr = rs.getString("LIB_ADDRESS");
String city = rs.getString("LIB_CITY");
String postcode = rs.getString("LIB_POSTCODE");

PrintWriter out = response.getWriter();
response.setContentType("text/html");

out.println("<html>");
out.println("<head><title>ULAL LIBRARY</title></head>");
out.println("<body bgcolor=#FFCC66>");
out.println("<br><center><h2>Librarian / Edit LIBRARY</h2></center>");
out.println("<form name=Add method=post action=/mhm029/servlet/Admin>");
out.println("<TABLE border=1 cellpadding=2 cellspacing=2 bordercolor=yellow>");
out.println("<tr><td>UNIVERSITY</td><td><INPUT type=text name=Uni_Name size=50 value=" + uni + "></td><td><Font color=red>*</Font></td></tr>");
out.println("<tr><td>PHONE</td><td><INPUT type=text name=phone size=50 value=" + phone + "></td><td><Font color=red>*</Font></td></tr>");
out.println("<tr><td>EMAIL</td><td><INPUT type=text name=email size=50 value=" + addr + "></td><td><Font color=red>*</Font></td></tr>");
out.println("<tr><td>ADDRESS</td><td><INPUT type=text name=address size=50 value=" + city + "></td><td><Font color=red>*</Font></td></tr>");
out.println("<tr><td>CITY</td><td><INPUT type=text name=city size=50 value=" + city + "></td></tr>");
out.println("<tr><td>POSTCODE</td><td><INPUT type=text name=postcode size=50 value=" + postcode + "></td><td><Font color=red>*</Font></td></tr>");
out.println("</TABLE>");

out.println("<Font color=red> * required</Font><br>");
out.println("<input type=submit name=submit value= Save >");
out.println("<input type=hidden name=Ad_No value=8>");

out.println("</form>");
out.println("</font>");
out.println("</body>");
out.println("</html>");
out.close();
}


}//try

catch (Exception e) {
throw new ServletException(e.getMessage());
}

finally {
if (con != null) {
try {
con.close();
}
catch (SQLException e) {
throw new ServletException("connection close failed");
}
}
}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 9 2006
Added on Apr 11 2006
6 comments
358 views