225 pts.
 What is wrong with my code?
Posed on behalf of SearchOracle member Deepa: Question: How can I get a oracle database connection? Here is a code to which accepts username and password and checks for validation. is it correct? Pls tel me import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.lang.String; public class Form extends HttpServlet{ private ServletConfig config; private String username=null; private String password=null; private Hashtable errors; public void init(ServletConfig config)throws ServletException{ this.config=config; } public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{ String username=null; String password=null; Hashtable errors; res.setContentType("text/html"); PrintWriter out=res.getWriter(); req.getSession(); username=req.getParameter("username"); password=req.getParameter("password"); try{ if(username!=null && username.equals("username")){ getServletConfig().getServletContext(). getRequestDispatcher("my projects/qpro/src/process"); }else{ errors.put("username" enter a valid name); username=""; } if(password==null){ errors.put("password" Enter a valid username); password=""; } else{ getServletConfig().getServletContext(). getRequestDispatcher("my projects/qpro/src/process "); } String getErrorMsg(String s){ String errormsg=(String)errors.get(s.trim()); return (errormsg==null) ? "":errormsg; } } catch(Exception e){ out.println(e.getMessage()); } out.println("<html><head><title>Enter username and passowrd</title></head>"); out.println("<body><center>Enter username and password</center>"); out.println("<br>"); out.println("<table align='center' cellspacing='2' cellpadding='0'>"); out.println("<tr>"); out.println("<td>UserName</td>"); out.println("<td><input type='text' name='Username' size='10' maxlength='15'></td>"); out.println("</tr>"); out.println("<tr>"); out.println("<td>Password</td>"); out.println("<td><input type='password' name='password' maxlength='15'></td>"); out.println("</tr>"); out.println("<tr>"); out.println("<td>"); out.println("<input type='button' value='Submit'></td>"); out.println("<td><input type='button' value='reset'></td>"); out.println("</tr>"); out.println("</table></body</html>"); } } public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{ doGet(req,res); } }

Software/Hardware used:
ASKED: October 18, 2005  6:43 AM
UPDATED: October 19, 2005  9:42 AM

Answer Wiki:
pass this connection string to oracle:- "Provider=MSDAORA.1;Password=;User ID= ;Data Source= Oracle's Host String ;Persist Security Info=True"
Last Wiki Answer Submitted:  October 19, 2005  9:42 am  by  Praveensethiya   0 pts.
All Answer Wiki Contributors:  Praveensethiya   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _