What is Java Servlet?

I read many articles to understand Java servlet but I did not succeed. Can you please give brief introduction of Java servlets (in easy language). What is a servlet? What are the advantages? I can’t understand the difference between server-side programming languages (PHP, ASP) and servlets. 12 Answers 12

Design Patterns web based applications [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago. Improve this question I am designing a simple web-based application. I am new to this web-based domain.I needed your … Read more

How can I upload files to a server using JSP/Servlet?

How can I upload files to server using JSP/Servlet? I tried this: <form action=”upload” method=”post”> <input type=”text” name=”description” /> <input type=”file” name=”file” /> <input type=”submit” /> </form> However, I only get the file name, not the file content. When I add enctype=”multipart/form-data” to the <form>, then request.getParameter() returns null. During research I stumbled upon Apache … Read more

How do servlets work? Instantiation, sessions, shared variables and multithreading

Suppose, I have a webserver which holds numerous servlets. For information passing among those servlets I am setting session and instance variables. Now, if 2 or more users send request to this server then what happens to the session variables? Will they all be common for all the users or they will be different for … 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

How to request.getParameterNames into List of strings?

Just construct a new ArrayList wrapping the keyset of the request parameter map. List<String> parameterNames = new ArrayList<String>(request.getParameterMap().keySet()); // … 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. Set<String> parameterNames = request.getParameterMap().keySet(); // … … Read more