当我点击提交按钮时,它不会去servlet页面下载该页面的原因

时间:2016-11-24 05:21:15

标签: html servlets

<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor="lightgray">
<fieldset>
  <legend align="center"><blink><font color="grakgreen">Registration</font></blink></legend>
<form action="SaveServlet" method="post">
<table align="center">
<tr>
<th colspan="6">APPLICATION FOR EMPLOYMENT<BR>(Pre-Employment Questionnaire)</th>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr bgcolor="lightgreen">
<th colspan="6">PERSONAL INFORMATION</th>
</tr>
<tr>
<td>NAME:</td>
<td><input type="text" name="lnam" value="" size="30" placeholder="last name"></td>
<td><input type="text" name="fnam" value="" placeholder="first name"></td>
<td colspan="2"><input type="text" name="mnam" value=""size="46" placeholder="middle name"></td>
</tr>
<tr>
<td>PRESENT ADDRESS:</td>
<td><input type="text" name="stree" value=""size="30"placeholder="Street or House NO:"></td>
<td><input type="text" name="cit" value="" placeholder="city"></td>
<td><input type="text" name="stat" value="" placeholder="state"></td>
<td><input type="text" name="zi" value="" placeholder="zip code"></td>
</tr>
<tr>
<td>PERMANENT ADDRESS:</td>
<td><input type="text" name="pstree" value=""size="30" placeholder="Street or House NO:"></td>
<td><input type="text" name="pcit" value="" placeholder="city"></td>
<td><input type="text" name="pstat" value=""placeholder="state"></td>
<td><input type="text" name="pzi" value="" placeholder="zip code"></td>
</tr>
<tr>
<td>PHONE NUMBER:</td>
<td><input type="text" name="phn" value="" size="30"placeholder="Phnoe number"></td>
<td colspan="2">ALTERNATE PHONE NUMBER:</td>
<td><input type="text" name="alpn" value=""placeholder="Alternate phone number"></td>
</tr>
<tr>
<td colspan="3">ARE YOU PREVENTED FROM LAWFULLY BECOMEING EMPLOYEED IN THIS COUNTRY BECAUSE OF VISA OR IMMIGRATION STATUS?</td>
<td colspan="2">Yes<input type="radio" name="ye" value="yes">No<input type="radio" name="ye" value="no"></td>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr bgcolor="lightgreen">
<th colspan="6">EMPLOYEMENT DESIRED</th>
</tr>
<tr>
<td>POSITION:</td>
<td><input type="text" name="positio" value="" size="30"></td>
<td>DATE YOU CAN START:</td>
<td><input type="text" name="cdat" value=""></td>
<td>SALARY DESIRED:</td>
<td><input type="text" name="salar" value=""></td>
</tr>
<tr>
<td>ARE YOU EMPLOYEED NOW?</td>
<td><input type="text" name="empno" value=""size="30"></td>
<td colspan="3">IF SO MAY WE INQUIRE OF YOUR PRESENT EMPLOYER? </td>
<td><input type="text" name="inquir" value=""></td>
</tr>
<tr>
<td>EVER APPLIED TO THIS COMPANY BEFORE?</td>
<td><input type="text" name="applie" value=""size="30"></td>
<td>WHERE?</td>
<td><input type="text" name="wher" value=""></td>
<td>WHEN?</td>
<td><input type="text" name="whe" value=""></td>
</tr>
<tr>
<td>REFERED BY:</td>
<td><input type="text" name="rnam" value=""size="30"></td>
</tr>
<tr>
</tr>
<tr bgcolor="lightgreen">
</tr>
<tr>
<th>EDUCATION</th>
<th>NANME AND LOCATION OF SCHOOL</th>
<th>*NO OF YEARS ATTENDED</th>
<th>*DID YOU GRADUATE?</th>
<th>SUBJECTS STUDIED</th>
</tr>
<tr>
<td>SSC</td>
<td><input type="text" name="schol" value=""size="30"></td>
<td><input type="text" name="year" value=""></td>
<td><input type="text" name="graduat" value=""></td>
<td><input type="text" name="subject" value=""></td>
</tr>
<tr>
<td>INTER/DIPLOMA</td>
<td><input type="text" name="nschol" value=""size="30"></td>
<td><input type="text" name="nyear" value=""></td>
<td><input type="text" name="ngraduat" value=""></td>
<td><input type="text" name="nsubject" value=""></td>
</tr>
<tr>
<td>DEGREE/B.TECH/B.E</td>
<td><input type="text" name="naschol" value="" size="30"></td>
<td><input type="text" name="nayear" value=""></td>
<td><input type="text" name="nagraduat" value=""></td>
<td><input type="text" name="nasubject" value=""></td>
</tr>
<tr>
<td>PG</td>
<td><input type="text" name="nameschol" value="" size="30"></td>
<td><input type="number" name="nameyear" value=""></td>
<td><input type="text" name="namegraduat" value=""></td>
<td><input type="text" name="namesubject" value=""></td>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr bgcolor="lightgreen">
<th colspan="6">GENERAL</th>
</tr>
<tr>
<td>SUBJECTS OF SPECICAL STUDY OR RESEARCH WORK</td>
<td><textarea rows="3" cols="35" name="specia"></textarea></td>
<td>SPECIAL SKILLS</td>
<td colspan="2"><textarea rows="3" cols="47" name="skill"></textarea></td>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr bgcolor="lightgreen">
<th colspan="6"><b>FORMER EMPLOYERS</b>(LIST BELLOW LAST THREE EMPLOYERS, STARTING WITH LAST ONE FIRST).</th>
</tr>
<tr>
<th colspan="2"> DATE MONTH AND YEAR</th>
</tr>
<tr>
<th>From</th>
<th>TO</th>
<th>NAME AND ADDRESS OF EMPLOYER</th>
<th>SALARY</th>
<th>POSITION</th>
<th>REAON FOR LEAVING</th>
</tr>
<tr>
<td><input type="text" name="fdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="tdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="nem" size="35"></td>
<td><input type="text" name="nsalar"></td>
<td><input type="text" name="npositio"></td>
<td><input type="text" name="nreaso"></td>
</tr>
<tr>
<td><input type="text" name="efdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="etdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="eem" size="35"></td>
<td><input type="text" name="esalar"></td>
<td><input type="text" name="epositio"></td>
<td><input type="text" name="ereaso"></td>
</tr>
<tr>
<td><input type="text" name="dfdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="dtdat" value="" placeholder="mm/dd/yyyy" size="28"></td>
<td><input type="text" name="dem"size="35"></td>
<td><input type="number" name="dsalar"></td>
<td><input type="text" name="dpositio"></td>
<td><input type="text" name="dreaso"></td>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr bgcolor="lightgreen">
<th colspan="6">REFERENCES:GIVE THE NAME NAMES OF 3 PERSONS NOT RELATED TO YOU, WHOM YOU HAVE KNOW AT LEAST ONE YEAR.</th>
</tr>
<tr>
<th>NAME</th>
<th>ADDRESS</th>
<th>BUSSINESS</th>
<th>YEARS ACQUAINTED</th>
</tr>
<tr>
<td><input type="text" name="unam" value=""></td>
<td><input type="text" name="uaddres" value=""></td>
<td><input type="text" name="ubusines" value=""></td>
<td><input type="text" name="uyea" value=""></td>
</tr>
<tr>
<td><input type="text" name="knam" value=""></td>
<td><input type="text" name="kaddres" value=""></td>
<td><input type="text" name="kbusines" value=""></td>
<td><input type="text" name="kyea" value=""></td>
</tr>
<tr>
<td><input type="text" name="nname" value=""></td>
<td><input type="text" name="naddress" value=""></td>
<td><input type="text" name="nbusiness" value=""></td>
<td><input type="text" name="nyear" value=""></td>
</tr>
<tr>
</tr>
<tr></tr>
<tr>
</tr>
<tr></tr>
</table>
<center>
<input type="reset" value="reset">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="submit">
</center>
</form>
</fieldset>
</body>
</html>

SaveServlet代码,我使用了注释

protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException 
{
    res.setContentType("html/text");
    PrintWriter out=res.getWriter();

    String lnam=req.getParameter("lnam");
    String fnam=req.getParameter("fnam");
    String mnam=req.getParameter("mnae");
    String stree=req.getParameter("stree");
    String cit=req.getParameter("cit");
    String stat=req.getParameter("stat");
    String zi=req.getParameter("zi");
    String pstree=req.getParameter("pstree");
    String pcit=req.getParameter("pcit");
    String pstat=req.getParameter("pstat");
    String pzi=req.getParameter("pzi");
    String phn=req.getParameter("phn");
    String alpn=req.getParameter("alpn");
    String ye=req.getParameter("ye");
    String positio=req.getParameter("positio");
    String cdat=req.getParameter("cdat");
    String salar=req.getParameter("salar");
    String empno=req.getParameter("empno");
    String inquir=req.getParameter("inquir");
    String applie=req.getParameter("applie");
    String wher=req.getParameter("wher");
    String whe=req.getParameter("whe");
    String rnam=req.getParameter("rnam");
    String schol=req.getParameter("schol");
    String year=req.getParameter("year");
    String graduat=req.getParameter("graduat");
    String subject=req.getParameter("subject");
    String nschol=req.getParameter("nschol");
    String nyear=req.getParameter("nyear");
    String ngraduat=req.getParameter("ngraduat");
    String nsubject=req.getParameter("nsubject");
    String naschol=req.getParameter("naschol");
    String nayear=req.getParameter("nayear");
    String nagraduat=req.getParameter("nagraduat");
    String nasubject=req.getParameter("nasubject");
    String nameschol=req.getParameter("nameschol");
    String nameyear=req.getParameter("nameyear");
    String namegraduat=req.getParameter("namegraduat");
    String namesubject=req.getParameter("namesubject");
    String specia=req.getParameter("specia");
    String skill=req.getParameter("skill");
    String fdat=req.getParameter("fdat");
    String tdat=req.getParameter("tdat");
    String nem=req.getParameter("nem");
    String nsalar=req.getParameter("nsalar");
    String npositio=req.getParameter("npositio");
    String nreaso=req.getParameter("nreaso");
    String efdat=req.getParameter("efdat");
    String etdat=req.getParameter("etdat");
    String eem=req.getParameter("eem");
    String esalar=req.getParameter("esalar");
    String epositio=req.getParameter("epositio");
    String ereaso=req.getParameter("ereaso");
    String dfdat=req.getParameter("dfdat");
    String dtdat=req.getParameter("dtdat");
    String dem=req.getParameter("dem");
    String dsalar=req.getParameter("dsalar");
    String dpositio=req.getParameter("dpositio");
    String dreaso=req.getParameter("dreaso");
    String unam=req.getParameter("unam");
    String uaddres=req.getParameter("uaddres");
    String ubusines=req.getParameter("ubusines");
    String uyea=req.getParameter("uyea");
    String knam=req.getParameter("knam");
    String kaddres=req.getParameter("kaddres");
    String kbusines=req.getParameter("kbusines");
    String kyea=req.getParameter("kyea");
    String nnam=req.getParameter("nnam");
    String naddres=req.getParameter("naddres");
    String nbusines=req.getParameter("nbusines");
    String nyea=req.getParameter("nyea");

    Empb b=new Empb();

    b.setLnam(lnam);
    b.setFnam(fnam);
    b.setMnam(mnam);
    b.setStree(pstree);
    b.setCit(cit);
    b.setStat(stat);
    b.setZi(zi);
    b.setPstree(pstree);
    b.setPcit(pcit);
    b.setPstat(pstat);
    b.setPzi(pzi);
    b.setPhn(phn);
    b.setAlpn(alpn);
    b.setYe(ye);
    b.setPositio(positio);
    b.setCdat(cdat);
    b.setSalar(salar);
    b.setEmpno(empno);
    b.setInquir(inquir);
    b.setApplie(applie);
    b.setWher(wher);
    b.setWhe(whe);
    b.setRnam(rnam);
    b.setSchol(schol);
    b.setYear(year);
    b.setGraduat(graduat);
    b.setSubject(subject);
    b.setNschol(nschol);
    b.setNyear(nyear);
    b.setNgraduat(ngraduat);
    b.setNsubject(nsubject);
    b.setNaschol(naschol);
    b.setNayear(nayear);
    b.setNagraduat(nagraduat);
    b.setNasubject(nasubject);
    b.setNameschol(nameschol);
    b.setNameyear(nameyear);
    b.setNamegraduat(namegraduat);
    b.setNamesubject(namesubject);
    b.setSpecia(specia);
    b.setSkill(skill);
    b.setFdat(fdat);
    b.setTdat(tdat);
    b.setNem(nem);
    b.setNsalar(nsalar);
    b.setNpositio(npositio);
    b.setNreaso(nreaso);
    b.setEfdat(efdat);
    b.setEtdat(etdat);
    b.setEem(eem);
    b.setEsalar(esalar);
    b.setEpositio(epositio);
    b.setEreaso(ereaso);
    b.setDfdat(dfdat);
    b.setDtdat(dtdat);
    b.setDem(dem);
    b.setDsalar(dsalar);
    b.setDpositio(dpositio);
    b.setDreaso(dreaso);
    b.setUnam(unam);
    b.setUaddres(uaddres);
    b.setUbusines(ubusines);
    b.setUyea(uyea);
    b.setKnam(knam);
    b.setKaddres(kaddres);
    b.setKbusines(kbusines);
    b.setKyea(kyea);
    b.setNnam(nnam);
    b.setNaddres(naddres);
    b.setNbusines(nbusines);
    b.setNyea(nyea);

    int status=EmpDbs.save(b);
    if(status>0)
    {
        out.print("<p>Record saved successfully!</p>");
        req.getRequestDispatcher("SoftEmp.html").include(req, res);
    }
    else
    {
        out.println("Sorry! unable to save record");
    }

    out.close();
}

}

当我点击提交按钮时,SaveServlet正在下载,如图所示,但是插入了值并且页面没有刷新/休息:

when i click on submit button SaveServlet is downloading like show in the IMG but values are inserted and page is not refersh/rested

1 个答案:

答案 0 :(得分:0)

尝试使用

<input type="submit" value="submit" name="submit"/>