现在想实现一个注册 页面
 我要在数据库里面判定该账户是否存在 (这个可以判定) 关键是我 servlect 里面判断后的 结果我想放在 jsp 里面显示出来 
问:怎么让jisp 页面显示出我servlet 里面的值
还有   <input type="file" id="aa">  谁知道 怎么获取这个控件的 值    value  获取不到谁要是有简单的验证码  代码也发个给我  谢谢

解决方案 »

  1.   

    //检查用户名是否已经存在
    $.ajax({
    type : "POST",
    url : "userAction.do?dispatch=isExitCode",
    data : "code="+loginName.value,
    success : function(msg) {
    if(msg=="1"){
    $('.remindOfUserName').html('该用户名已经被占用,请选择其他用户名!').css('color','red');
    loginName.select();
    return false;
    }else{
    $('.remindOfUserName').html('恭喜,该用户名可用!').css('color','green');
    }
    }
    });
      

  2.   

    你这样把值存进作用域里面,再到页面用<%%>这种方式取出来
    验证码网上有很多的例子,你随便搜个验证码的jsp页面在一调用就行了,很简单的!
      

  3.   


    onblue 触发事件  ajax请求后台 上面有代码。
      

  4.   

    伪代码,按照自己的代码改一下。//servlet中,将结果保存到request作用域。
    if(true){
        request.setAttribute("isreg", "可以注册");
    }else{
        request.setAttribute("isreg", "不可以注册");
    }//jsp页面
    ${isreg}
      

  5.   

    还有,你的单词写错,是servlet不是servlect。
      

  6.   


    还是有点不会啊看我代码
    String name=request.getParameter("email");

    chaXunUser cx=new chaXunUser();
    boolean b=cx.selectUser(name);
    if(b){
    //这里面是注册不成功的内容 }这个是 servlet的  代码   已经可以判定了   怎么返回注册不成功的内容   个jsp页面啊
      

  7.   

    用ajax检查啊,这个很简单,你在后台写一个方法,验证用户是否存在,如果存在就返回true,否则返回false
    代码和1楼没有多大区别,你有什么不懂的地方问出来
      

  8.   

    <input type="file" id="aa">这个值能取到,ie7及以前的版本能,现在的浏览器都提高了安全级别,所以这个要想获取到很困难,我之前尝试过很多方法,但是最终还是利用iframe的伪ajax来实现的……
      

  9.   


    function likai(){
    if(document.getElementById("aa").value!=""){
    document.getElementById("aa").value=${isreg};
    }
    }这样 也不行啊
      

  10.   

    ajax   不怎么会   String name=request.getParameter("email");chaXunUser cx=new chaXunUser();
    boolean b=cx.selectUser(name);
    if(b){
    //这里用什么方法返回 true 或  false   
    }还有就是   JSP  页面怎么接受啊
      

  11.   

    function likai(){
    if(document.getElementById("aa").value!=""){
    document.getElementById("aa").value=${isreg};
    }
    }
    你这个代码是做什么用的?
    aa是一个file标签,怎么能这样操作。
    ${isreg}这个是显示你保存在作用域的值。
      

  12.   


    function likai  是我一个  鼠标离开触发的函数
    这个我知道   aa  是我账户文本域的  id   我要判断 是否输入过  账户 如果有输入就  执行检测 账户是否存在啊
      

  13.   

    直接返回就是了 return false
    return ture
    得了 我给你写一个你看着把//检查用户名是否已经存在
    $.ajax({
    type : "POST",
    url : "userAction.do",
    data : "userName="+loginName.value,//这里去后台取userName这个变量
    success : function(msg) {
    if(msg==true){
       alert("用户名重复,请您重现填写");
    }else
       alert("用户名正确!");
    });那里有不懂速度问
      

  14.   


    哥哥们 我也很纠结啊    我在  servlet  里面会返回   关键是我  在  jsp  页面中就不会接收了  就是这个 
      

  15.   

    这个是我数据库  里面查询的代码public boolean selectUser(String name){
    boolean bl=false;
    String sql="select uname from users where uname=?";
    Connection conn=DBUtil.getConnection();
    PreparedStatement pst=null;
    ResultSet rst=null;
    try {
    pst=conn.prepareStatement(sql);
    pst.setString(1, name);
    rst=pst.executeQuery();
    if(rst.next()){
    bl=true;
    }
    } catch (SQLException e) {
    e.printStackTrace();
    }finally{
    try {
    DBUtil.close(conn, pst, rst);
    } catch (SQLException e) {
    e.printStackTrace();
    }
    这个是我 servlet 里面 的代码  String name=request.getParameter("email");

    chaXunUser cx=new chaXunUser();
    boolean b=cx.selectUser(name);
    if(b){
    request.setAttribute("isreg", "可以注册");
    }else{request.setAttribute("isreg", "不可以注册");}这个是  我JSP 页面里面的代码:
    <script type="text/javascript">
    function ciclk(){
    document.getElementById("aa").value="";
    }

    function likai(){
    if(document.getElementById("aa").value==""){
    document.getElementById("aa").value="支持,中,英,数字";
    }
    if(document.getElementById("aa").value!=""){
    //document.getElementById("aa").value=;
    }
    }
    </script>
    <td>注册账户:</td>
    <td align="left"><input id="aa" type="text" name="email" value="支持,中,英,数字" onclick="ciclk()" onblur="likai()"></td>
      

  16.   

    哥哥们   在知道我 想问的是 什么了吧  我想问的是   鼠标离开 这个<input id="aa" type="text" name="email" value="支持,中,英,数字" onclick="ciclk()" onblur="likai()">  的时候  就查询是否存在账户  
      

  17.   


    借用一下八楼哥们的代码function likai(){
       if(document.getElementById("aa").value==""){
           document.getElementById("aa").value="支持,中,英,数字";
       }
       if(document.getElementById("aa").value!=""){
          var username = document.getElementById("aa").value;
          $.ajax({
               type : "POST",
               url : "userAction.do",  //这个看你web.xml里面怎么配置的
               data : "userName="+username,//这里去后台取userName这个变量
                 success : function(msg) {
               if(msg=="success"){
                   alert("用户名重复,请您重现填写");
               }else{
                  alert("用户名正确!");
               }
           });
       }
    }
    -------------------华丽的分割线--------------------servlet代码String name = request.getParameter("userName"); 
    chaXunUser cx=new chaXunUser();
    boolean b=cx.selectUser(name);
    PrintWriter pw = response.getWriter();
    if(b){
         pw.write("success");    
    }else{
         pw.write("error");
    }
    pw.close();
    return;