Archive

Posts Tagged ‘create and run simple jsp program using apache tomcat’

Create simple JSP program using tomcat

December 22, 2010 8 comments

Create and Run a simple JSP program using tomcat

Here I am going to explain for write create a simple jsp program and run that program in apache tomcat. This process has some steps. The following steps are based on windows operating system

Step 1: Download latest Apache Tomcat and install machine.

Example: The tomcat installed location (C:/Program Files/Apache Software  Foundation/Tomcat 6.0/)
After installation, the tomcat folder has the following files are  bin, conf, lib, logs, temp, webapps and work.

Step 2 : Create directory “myjsp” and “simple_programs” under the webapps
C:/ Program Files/Apache Software Foundation/Tomcat 6.0/webapps/myjsp/simple_programs

Step3 : Create simple jsp program. The program name as “helloworld.jsp”


<%-- 
    Document   : helloworld
    Created on : Dec 20, 2010, 10:20:48 PM
    Author     : eswar
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>

        <p> Hi, <h3><%="Hello!" %></h3></p>
        <p>You successfully run a simple jsp program.</p>
        <p>Learn More concept about jsp.</p>

    </body>
</html>

Step 4: Save this file the following location :
C:/ Program Files/…/…/webapps/myjsp/simple_programs/helloworld.jsp

Step 5: Before run this code, know some details about tomcat.
apache-tomcat-port-information

Stpe 6: Run jsp program
a)Start the tomcat service
Start -> run -> services.msc -> Select Apache Tomcat -> start

b)Open new tab in browser or open new window :
http://localhost:8080/myjsp/simple_programs/helloworld.jsp

Now you will get the output as :
Hi, Hello!
You successfully run a simple jsp program.
Learn More concept about jsp.