java - servlet programming -


I am using these servlet codes in the I process queue method, as variable ans, id ... IOM is not getting into the doppost method. I am having a problem with double quote ....

  Secure zero process request (HTTsProvider request request, HTPS) throws ServletException, IOException {response.setContentType ("text / html"); PrintWriter out = response.getWriter (); Try out {Out.println ("& lt; html>"); Out.println ("top> gt;"); Out.println ("& gt; Title & gt; Servlet Admin"  "); Out.println ("& lt; / head>"); Out.println ("k & lt; body & gt;"); Out.println ("& lt; form METHOD = POST & gt;"); Out.println ("Enter ID Number"); Out.println ("& lt; INPUT TYPE = TEXT name = id>"); Out.println ("& lt; br & gt;"); Out.println ("Enter Answer."); Out.println ("& lt; INPUT TYPE = text name = answer>"); Out.println ("& lt; br & gt;"); Out.println ("& lt; INPUT TYPE = SUBMIT VALUE = Submit & gt;"); Out.println ("& lt; / form & gt;"); Out.println ("& lt; / body & gt;"); Out.println ("& lt; / html>"); } Finally {out.close (); }}    

Note points:

  • when Until you are using Servlets for the very first time and trying to understand the technology, in fact you should not use the servlet for output HTML - a JSP is better suited for this.
  • - Dangerous is not XML (and therefore XHTML), which means that & lt; Form & gt; and & lt; Form & gt; There are various elements now for this conference to use lower-case for all elements, then you not should be used; Instead & lt; Input & gt; Use goes to the same properties ( value not VALUE ).
  • Note that you can either use double quotes " or ' for attributes in the X (HT) ML. / Li>

    And if I understand you correctly, you are saying that you are unable to read the field when you submit it and you suspect it because you double the string If you are unable to add quotation marks, then you have to write here: double string within the string There is a simple case to avoid:

      out.println ("& lt; html>"); out.println ("& lt; head>"); out Println ("& gt; Title & gt; Servlet Administrator Form & lt; / title & gt;"); Println ("& lt; / head>"); out.println ("& lt; body & gt; "Out.println (" 
    "); out.println (" reply. "); Out.println (" & lt; INPUT type = \ "text \" name = \ "ans> \" "); out.println (" & lt; Br & g; "); Out.println (" & lt; INPUT type = \ "SUBMIT \" VALUE = \ "submit \" & gt; "); out.println (" & lt; / form & gt; "); out .println ("& lt; / body & gt;"); out.println ("& lt; / html>");

    Or if you have the same quote ( Also makes java code easier to write):

      out.println ("& lt; html & gt;"); out.println ("& lt; top & gt; ; "Out.println" (title & gt; Servlet Administrator & lt; / title & gt; "); out.println (" & lt; / head> "); out.println (" Out.println ("& lt; form METHOD = 'POST & gt;' '); Out.println (" Enter ID Number "); Out.println (" & lt; & lt; body & gt; ; INPUT TYPE = 'TEXT' name = 'id' & gt; "); out.println ("& Lt; br & gt;"); Out.println ("Enter Answer."); Out.println ("& lt; INPUT TYPE = 'TEXT' name = 'ans & gt;'"); out .println ("& lt; br & gt;"); Out.println ("& lt; INPUT Type = 'SUBMIT' VALUE = 'Submit' & gt;"); out.println ("& lt; / Form & Gt; "); out.println (" & lt; / body & gt; "); Out.println ("& lt; / html>");    

Comments