Okay, I have no idea about what I am doing exactly but I am trying to understand it through sample programs and snippets. To be clear, my concepts are missing. So I might be having an error which is very obvious (not to me).
I am creating a simple username-password field on a localhost and need to be able to use the textfield inputs to match them. My page shows the buttons and fields properly(index.htm in WEB-INF) but my java class needs to get the string values. I get it that form actions need URL but how can I send it to my java clasS? I tried using request.getParamater("id") but it says no attached doc.
below is the html part
<!DOCTYPE html>
<html>
<head><title> Multi Factor Authentication Prototype </title>
<link rel="stylesheet"
href="./css/styles.css"
type="text/css"/>
</head>
<body>
<table class="title">
<tr><th>Multi-factor Authentication, level 1 prototype </th></tr>
</table>
<p/>
<fieldset>
<form name="mfa1" action="check" method="post">
<legend> Login </legend> <ul> <br />
Username : <input title="Please Enter the Username" id="uname" name="uname" type="text" size="20" /><br />
<br />
Password : <input title="Please Enter your password" id="pwd" name="pwd" type="password" size="20" /><br />
<br />
</body>
</html>
here is java class. It says no java doc referred in request field and yes, doesn't display anything.
package test;
import java.io.*;
import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.*;
import java.lang.*;
@WebServlet("/check")
public class TestServlet extends HttpServlet{
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
String un = request.getParameter("uname");
PrintWriter out = response.getWriter();
out.println
("<!DOCTYPE html>\n" +
"<html>\n" +
"<head><title>tuiy</title></head>\n" +
"<body bgcolor=\"#fdf5e6\">\n" +
"<h1>"+un+"</h1>\n" +
"\n" +
"</body></html>");
}
}
or is there a way to insert if/else clauses and various functions in the same dcument? I would really prefer if you could help me point out the way to get the parameters in java.