java - Send parameters from JSP to Servlet using POST -


i building simple web app , attempting create login page. page consists of jsp form loads servlet.

i have got form working using method:

jsp looks this:

<form method="get" action="login"> email:<input name="email"/> password:<input name="password"/> <input type="submit" value="log in"/> 

and in servlet:

@webservlet(name = "login", urlpatterns = {"/login"}) public class login extends httpservlet {  /** * processes requests both http * <code>get</code> , * <code>post</code> methods. * * @param request servlet request * @param response servlet response * @throws servletexception if servlet-specific error occurs * @throws ioexception if i/o error occurs */ protected void processrequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html;charset=utf-8");  //assign variables request parameters string loginformemail = request.getparameter("email"); string loginformpassword = request.getparameter("password"); 

this code works includes username , password in url string, it's not practice. have attempted using post instead i've been getting error. (http status 405 - http method post not supported url)

i need know how send parameters jsp servlet using post. think may involve using requestdispatcher object, tutorials i've found explain using requestdispatcher send data servlet jsp, not other way around. can you/should use request dispatcher send post data jsp servlet? , how access these parameters servlet? (is there equivalent of request.getparameter() post?)

i understand using post still won't secure, lot better practice including password in query string, , think security later.

apologies basic question, have found lots of tutorials online none of them seem answer specific question. thank you.

try

<form method="post" action="login> 

note: method instead of type specifying get/post.

but it's not more "secure" using get. still available in clear text in post body. if want secure, make sure use https.

edit

you have edited question now, , appears using method, not type. if still have errors after changing post, specify error getting.

edit2

you specify getting http method post not supported url error. means servlet not accept post method. means inheriting base servlet accepts get. seeing of code servlet helpful.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -