Servlets

What is SingleThreadModel in Servlets?

1. What is SingleThreadModel? It is an interface from javax.servlet package used with Servlets. It is marker interface having no methods. Few servlets may require this to implement. 2. Are Servlets multithreaded? Yes, Servlets are multithreaded being Java supports multithreading. 3. Explain how Servlets are multithreaded? First time when a request comes to a Web …

What is SingleThreadModel in Servlets? Read More »

getRemoteHost() Method Example

This method is defined in ServletRequest interface from javax.servlet package inherited by HttpServletRequest. With this method, the servlet programmer can know the name of the client from which the request came. Let us see what Java API says about this method. java.lang.String getRemoteHost(): Returns the fully qualified name of the client or the last proxy …

getRemoteHost() Method Example Read More »

Servlet Read text file and Return contents Example

Sometimes, the client may ask the Servlet to send the file contents of a file existing on the server. It is not file download. Here, the Servlet reads manually line-by-line and send each line separately to client. Read Servlet Read text file. Example on Servlet Read text file Client HTML Program: TextFileReadAndSend.html Getting File contents …

Servlet Read text file and Return contents Example Read More »

Servlet WAR File Weblogic Creation Deployment

Servlet WAR File Weblogic Creation, Deployment and Execution is shown step-by-step for a Beginner. With the release of the Java Servlet Specification 2.2, the concept of a Web application was introduced. According to this specification, a "Web Application is a collection of servlets, html pages, classes, and other resources that can be bundled and run …

Servlet WAR File Weblogic Creation Deployment Read More »

getRemoteAddr() Method Example

getRemoteAddr() method is defined in ServletRequest interface from javax.servlet package inherited by HttpServletRequest. With this method, the servlet programmer can know the IP address of the client from which the request came. Let us see what Java API says about this method. String getRemoteAddr(): Returns the Internet Protocol (IP) address of the client or last …

getRemoteAddr() Method Example Read More »

Servlet Cookies Simple Shopping Cart Example

Note: You can see the JESSIONID (Session ID) in the output screens at the end. Note: For better understanding, the subject is discussed in Question/Answer format. Note: Before going into this example, it is advised to go through the Cookie API methods and their explanation because these methods are used in this example. 1. What …

Servlet Cookies Simple Shopping Cart Example Read More »