How to request.getParameterNames into List of strings?

Just construct a new ArrayList wrapping the keyset of the request parameter map. I only wonder how it’s useful to have it as List<String>. A Set<String> would make much more sense as parameter names are supposed to be unique (a List can contain duplicate elements). A Set<String> is also exactly what the map’s keyset already represents. Or perhaps you don’t need it at all for the particular functional requirement … Read more

What is Java Servlet?

A servlet is simply a class which responds to a particular type of network request – most commonly an HTTP request. Basically servlets are usually used to implement web applications – but there are also various frameworks which operate on top of servlets (e.g. Struts) to give a higher-level abstraction than the “here’s an HTTP … Read more

HTTP Status 405 – HTTP method is not supported by this URL

This is the default response of the default implementation of HttpServlet#doXxx() method (doGet(), doPost(), doHead(), doPut(), etc). This means that when the doXxx() method is not properly being @Overriden in your servlet class, or when it is explicitly being called via super, then you will face a HTTP 405 “Method not allowed” error. So, you … Read more

getting error HTTP Status 405 – HTTP method GET is not supported by this URL but not used `get` ever?

The problem is that you mapped your servlet to /register.html and it expects POST method, because you implemented only doPost() method. So when you open register.html page, it will not open html page with the form but servlet that handles the form data. Alternatively when you submit POST form to non-existing URL, web container will … Read more