daily pastebin goal
85%
SHARE
TWEET

Untitled

a guest Feb 11th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. RequestDispatcher rd = request.getRequestDispatcher("/altaPerfil.jsp");
  2. rd.forward(request, response);
  3.    
  4. <form action="altaPerfilServlet"
  5.       name = "frmValidar"
  6.       method='post' enctype='multipart/form-data' >
  7.  
  8.     Nick:
  9.     <br />
  10.     <input type="text" name="nick"
  11.            id="nick" onkeypress="deshabilita()"
  12.            value="${requestScope.nick}" />
  13.  
  14. <input type=button name="botonValidar"
  15.            id="botonValidar" value="Validar datos"
  16.            onclick="validarNick()" />
  17. <!--Note: the javascript validarNick() verifies the nick field and if it is -->
  18. <!--not empty then it calls frmValidar.submit()-->
  19.    
  20. FileItemFactory factory = new DiskFileItemFactory();  
  21.   ServletFileUpload upload = new ServletFileUpload(factory);
  22.  
  23.   List<FileItem> fields = upload.parseRequest(request);
  24.   Iterator<FileItem> it = fields.iterator();
  25.  
  26.   <!--here i process all the FileItems and obtain their values-->
  27.   <!--then i talk to a java app (which acts as a server, providing -->
  28.   <!--the data and a series of classes) and obtain a boolean value(esValido)-->
  29.   <!--that tells me if the nick is available(true) or taken(false)-->
  30.  
  31.   <!--finally: -->
  32.  
  33.   request.setAttribute("esValido", esValido);<!-- saving the boolean -->
  34.  
  35.   String nick=request.getParameter("nick");
  36.   request.setAttribute("nick", nick);
  37.   RequestDispatcher rd = request.getRequestDispatcher("/altaPerfil.jsp");
  38.   rd.forward(request, response);
  39.    
  40. <form method="post" action="servlet_url">
  41.   No   : <input type="text" name="no" value="${requestScope.no}"/>
  42.   Name : <input type="text" name="name" value="${requestScope.name}"/>
  43.   <input type="submit"/>
  44. </form>
  45.    
  46. String no=request.getParameter("no");
  47. String name=request.getParameter("name");
  48.  
  49. //other statements
  50.  
  51. request.setAttribute("no",no);
  52. request.setAttribute("name",name);
  53.  
  54. RequestDispatcher rd = request.getRequestDispatcher("/sample.jsp");
  55. rd.forward(request, response);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top