Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following is an example i use in tomcat. It will get you all parameters that are send in a POST or GET request. Be advised that this does not cover multicast requests (which are needed for file transfers).<br> I don't know if it will work for you, as you have not specified you servlet container.</p> <pre><code>import java.io.*; import javax.servlet.*; import javax.servlet.annotation.WebServlet; import javax.servlet.http.*; import java.util.*; @WebServlet(description = "A simple request test.", urlPatterns = { "/requesttest" }) public class RequestTest extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String title = "Reading All Request Parameters"; out.println("&lt;BODY BGCOLOR=\"#FDF5E6\"&gt;\n" + "&lt;H1 ALIGN=CENTER&gt;" + title + "&lt;/H1&gt;\n" + "&lt;TABLE BORDER=1 ALIGN=CENTER&gt;\n" + "&lt;TR BGCOLOR=\"#FFAD00\"&gt;\n" + "&lt;TH&gt;Parameter Name&lt;TH&gt;Parameter Value(s)"); Enumeration&lt;String&gt; paramNames = request.getParameterNames(); while(paramNames.hasMoreElements()) { String paramName = (String)paramNames.nextElement(); out.println("&lt;TR&gt;&lt;TD&gt;" + paramName + "\n&lt;TD&gt;"); String[] paramValues = request.getParameterValues(paramName); if (paramValues.length == 1) { String paramValue = paramValues[0]; if (paramValue.length() == 0) out.print("&lt;I&gt;No Value&lt;/I&gt;"); else out.print(paramValue); } else { out.println("&lt;UL&gt;"); for(int i=0; i&lt;paramValues.length; i++) { out.println("&lt;LI&gt;" + paramValues[i]); } out.println("&lt;/UL&gt;"); } } out.println("&lt;/TABLE&gt;\n&lt;/BODY&gt;&lt;/HTML&gt;"); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } </code></pre> <p><strong>EDIT</strong><br> Seeing as you edited your question with your servlet code, the answer should be really simple.</p> <pre><code> String s2=request.getParameter("pass1"); </code></pre> <p>This should get you the value that is transmitted within the password field. This is no different than you getting the username with <code>String s1=request.getParameter("username");</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload