Eclipse maven servlet hello world

Eclipse maven servlet hello world: Eclipse provides m2eclipse plugin to integrate Maven and Eclipse together. Steps to create maven java web project in eclipse: In eclipse, click on File menu → New → Maven Project. Select maven-archetype-webapp template to create java project and Click on Next button. Now provide the group Id, artifact Id and … Read more

java servlet example in eclipse

Java Servlet “Hello World” example by implementing Servlet interface.View—Download. Java Servlet “Hello World” example by extending GenericServlet class.View—Download. Java Servlet “Hello World” example by extending HttpServlet class.View—Download. Java Servlet Deployment Descriptor web.xml file example.View—Download. Java Servlet welcome-file-list in web.xml example.View—Download. Java Servlet RequestDispacher interface forward and include example.View—Download. Java Servlet sendRedirect example.View—Download. Java Servlet Init … Read more

Java FilterConfig interface

FilterConfig object is created and used by the web container to pass init parameters to a filter during initialization. Methods of FilterConfig interface: 1. getFilterName(): Returns the name of the filter defined in web.xml. Syntax: public String getFilterName() 2. getInitParameter(String name): Returns the value of the specified parameter. Syntax: public String getInitParameter(String name) 3. getInitParameterNames(): … Read more

Servlet HttpSession

HttpSession: HttpSession is an interface that provides a way to identify a user in multiple page requests. A unique session ID is given to the user when the first request comes. This ID is stored in a request parameter or in a cookie. How to get a session object? HttpServletRequest interface’s getSession() method is used … Read more

URL rewriting in servlet

URL rewriting: URL rewriting is a way of appending data at the end of a URL. Data is appended in name-value pair form. Multiple parameters can be appended in one URL with name-value pairs. Syntax: URL?paramName1=paramValue1& paramName2=paramValue2 How to get the parameter value from url in the servlet? HttpServletRequest interface’s getParameter() method is used to get … Read more

Servlet Hidden fields

Hidden field: Hidden field is an input text with hidden type. This field will not be visible to the user. Syntax: input name=”fieldName” value=”fieldValue” type=”hidden” How to get hidden field value in servlet? HttpServletRequest interface’s getParameter() method is used to get hidden field value in servlet. Syntax: String value = request.getParameter(“fieldName”);   Note: Hidden field only works … Read more

Cookie in servlet

Cookie: A cookie is a small piece of information as a text file stored on client’s machine by a web application. How cookie works? As HTTP is a stateless protocol so there is no way to identify that it is a new user or previous user for every new request. In case of cookie a … Read more