servlet cookies


Web tier: servlets, JSP, Web frameworks: servlet cookies

  1. servlet cookies (1 messages) to get all the names at one time using cookies or HttpSession?
    2.the search dialog box present in a different frame does not get refreshed each time the search is to overcome this?
    3.the part of the frame which displays the name also does not get refreshed.what to do?

    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;

    public class dnscook extends HttpServlet
      PrintWriter out;
      String vhost_name;
      String ext;
      boolean correct = false;
      String name;
      int i;
      public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
          out = res.getWriter();
          out.println("<form action=''method=POST>");
          Connection con = DriverManager.getConnection("jdbc:odbc:dc");
          Statement st = con.createStatement();
          ResultSet rs = st.executeQuery("select * from dns");
           vhost_name = req.getParameter("vhost_name");
           ext = req.getParameter("extension");
           if(vhost_name.equals(rs.getString(1)) && ext.equals(rs.getString(2)))
              correct = true;
               out.println(vhost_name+ext+" "+"already exists");
               // out.println(" your name "+" "+dname+" "+ext+" "+"is avialable");
                Cookie cookie = new Cookie("Names",vhost_name);
                out.println(vhost_name+" "+ext);
                correct = false;
        }catch(Exception e){}

    the source code for html file

    <form action= "" name=whois method=POST target=lowerright>
    <table border='0' width='66%' bgcolor='pink' cellpadding='0' cellspacing='0'>
       <td width='20%'>
          <p align='center'>
            <font face='CG Times' color='black'size=3>
              <strong>Check Available domain name of your choice</strong></font></td></tr>
             <tr bgcolor='#ffffe2'>
           <td width='50%'><table border='0' bgcolor='#c0c0fff' >
            <td width='18%'>
              <p align='right'><font color='#FFFFFF'>
         <td width='32%'>
           <INPUT type='text' name=vhost_name size=20>
       <td width='25%'>
          <select name='extension' size='1'>
             <option value='All'>All </option>
               <option value='.com'>.com </option>
                <option value='.net'>.net </option>
                <option value='.org'>.org </option>
         <td width='25%'>
            <INPUT type=submit value='Check it' ></INPUT>

    the source code for main main containing frame

    <Frameset cols = "20%%,*" border NORESIZE SCROLLING="NO">
        <Frame name="TOP" src=ex1.html >
      <Frameset rows = "70%,*">
       <Frame name="lowerright" src="b.html">
      <Frame name="lowerright1" src=dosample.html>

    Threaded Messages (1)

  2. servlet cookies[ Go to top ]

    My friend.

    The error is with the instance variable "correct".
    You better modify your servlet code like the following..

    if(vhost_name.equalsIgnoreCase(rs.getString(1).trim()) && ext.equalsIgnoreCase(rs.getString(2).trim()))
    correct = true;
       correct = false;

    Don't think that the servlet instance variables are re-initialized every time the servlet is called.

    Servlet will have only one instance during its life cycle.


    (rockmania hacks java for food)
    (rockmania is a Sun certified Java Programmer)
    (rockmania is a Sun certified Java Developer)
    (rockmania is an IBM certified Solution Developer for WebSphere Advanced Version)
    (rockmania is BEA certified Weblogic server developer)