Posts

Showing posts from May, 2022

Create a Dynamic Web Application in eclipse

Image
Java Servlet Tutorial In java, to develop a dynamic web application, servlets are used . Servlets are server side programs. This tutorials explains to you how to create a servlet in eclipse and run in server(tomcat).   ServletsHome Create Web Application   Go to File Menu   select New → Dynamic Web Application → Enter project name → click Finish . Create Servlet Right click on project that you created and select New → Servlet It opens " CreateServlet "  window and enter the servlet name and click New → New → Finish It creates a servlet with following code with  import java.io.IOException ; import java.io.PrintWriter ; import javax.servlet.ServletException ; import javax.servlet.http.HttpServlet ; import javax.servlet.http.HttpServletRequest ; import javax.servlet.http.HttpServletResponse ; /** * * @author somanew */ public class FirstServlet extends HttpServlet { /** * Processes requests for both HTTP <code>GET</code> and <co

Sending Parameters to Servlet

Image
 Sending Parameters to Servlet in Java     ServletsHome Sometimes the user request may contain some data. It is sent through URL in the form of  name value pairs. This is generally known as a query string. When URL submitted servlet will read this data from the query string, process it and sends a response back to the user.   Today, you are going to lean how to pass data and read it in servlet.  Sending Parameters to Servlet using query string → In the URL after the servlet name query string  added. → Query string and URL separated by  ' ? ' . →   with query string, we pass parameter name  values to servlet. http: // localhost:8080/FirstWebApplication/PostParameterServlet ? name=abc Here we are using a simple GenericServlet example. A service method taking two parameters - request , response Inside the service method, a PrintWriter object reference(out) is created.  That point to the PrintWriter object, which is return by response.getWriter(). Using out object println() m

Running Java Webapplication in Eclipse

Image
 Create First Web Application in Java using Eclipse     Web application generally run in Server. In Java, we mostly use an editor to create any web application. In this tutorial, we are using eclipse editor to create a web application in Java. To run a web application, you need to integrate a web server to eclipse. Usually it is Tomcat server. If not yet done, please check out this link and proceed with this tutorial. So First… Start Eclipse. 1. Go to File menu and select New and click on Dynamic Web Project . As shown in picture.     2. Enter the web application name  FirstWebApplication and click on next button. 3. click next. 4. Select Checkbox ' Generate web.xml deployment descriptor ' and click Next.    5. Click Finish.      6. Right click on Project and select new and select Html file. and give name as index.htnl.     7. A new HTML file  created. In HTML page inside the <body> tag, type ' Hello '  and save it.               8. Run the web application. Rig

Java Servlets Introduction Tutorial

Image
  Java Servlets Introduction Tutorial Servlets Home  In a Java Web Application to communicate with server we need servlets. Servlet receives user request and send response. In this tutorial, you are going to learn, All about  Java Servlets and their types and its lifecycle methods.    Table of Contents Introduction to Servlets Servlet life cycle Servlets Hierarchy Servlet Interfaces Servlet Classes HTTPServlet Package    Introduction to Servlets Servlets run at server. i.e., they are server side programs which serves to client request.  One servlet can serve to multiple requests. When request  made to particular servlet It is loaded in memory and initialized and next It will serve the request. If it is no longer required, it is destroyed from memory. Servlet life cycle init service destroy All the servlet built-in classes are available in a package called. To create a servlet, you need to import the following package. javax. servlet Package TOP Menu Servlets Hierarchy The below ima

Include Tomcat and Eclipse in Java

Image
      Learn How to include Tomcat in Eclipse in Java    Java Tutorial Home First Download the Eclipse if not yet done. Choose JavaEE, based on your operating system(64 bit/32 bit) download and install it. You get it as a zip. Just extract it and copy to a drive C or D from where you want to run it. Include java (jre) to eclipse.    1. Start Eclipse. Create New Web application               2.Provide, Project Name : FirstWebApplication      3. Click Next. 4. Select  Generate Web.xml option and Click Next.     5.  Click Finish      6. RightClick Project select Run as → Run on Server 7. Select >Apache   from select server type. It shows server that is available in PC.     8. Select the server version that you installed on PC.Click Next.     9. Locate Tomcat Server with Browse Button or Paste directly the path of the Tomcat. Next Change the JRE if not showing the current version that in available the PC. click Next.       10. Now you can see the Server name in the servers Tab. Right cl

Installing Apache Tomcat on Windows-10

Image
         Java Tutorial Home   ServletsHome    Installing Tomcat Server in Java   Apache Tomcat is a Server, used to run Java Web Applications. In order to run Servlets(Java Server Programs). You need a server. Servlet resides in Server and responses to clients requests. The most popular server that is used for java web applications is Apache Tomcat Server.  This blog shows how to install Apache Tomcat Server on Windows 10. Just follow the steps given below. 1. Download Download the latest version of Tomcat from Apachi Tomcat Click on  32-bit/64-bit Windows Service Installer link, and download it.   2. Installation- run the setup file with Default Settings. Once it is installed, You need to set the path variables. 3. Setting environment variables.     a. Open File explorer and right click on  This PC and select Properties , it Opens System settings window .               b. Select Advanced System Settings as shown in the image given below.   4. Setup Variables. Select Environment