web.xml deployment descriptor

web.xml deployment descriptor

Pls guide about how to write the web.xml file to deploy our web applications that uses JSP, by using tomcat...

View Answers

February 22, 2008 at 8:48 PM

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
}
}


<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/HelloWorld</url-pattern?>
</servlet-mapping>


February 22, 2008 at 9:10 PM

Hi,

Here I am assuming that you have already downloaded and intalled the tomcat on your machine and you are able to access http://localhost:8080. On typing http://localhost:8080 your browser shows the tomcat?s default page.

Now I am going to explain you the process to create web application, write hello world jsp file and then check on the tomcat server.

Step 1:
Stop the tomcat

Step 2:

Go to tomcat?s webapps directory and create the following directory:

[tomcat-root]/webapps
|_ test
|_ WEB-INF
|_ classes

here test is the name of web application.

Step 3:

Now create hello world jsp page in the test directory. Here is the code of hello.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
<BODY>
<%="Hello World!"%>
</BODY>
</HTML>

Step 4:

Now Start the tomcat server.

Step 5:

Now you can test your application. To test the example type http://localhost:8080/test/hello.jsp

You browser should display the hello world message.

Hope you will help in getting started with JSP in tomcat.

Thanks

February 22, 2008 at 9:23 PM

Hi,

Here is the code of web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">;


</web-app>

Save the web.xml file into WEB-INF directory.

You can declare your servlet into web.xml file.

<!-- Hello World Servlet -->
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloWorld</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/Hello</url-pattern>
</servlet-mapping>

To access the servlet you have to type http://localhost:8080/test/Hello into browser.

Thanks









Related Tutorials/Questions & Answers:
What are the elements in the deployment descriptor(web.xml)?
What are the elements in the deployment descriptor(web.xml)?  What do the following elements in the deployment descriptor(web.xml)are: â?¦â?¦.. â?¦.. â?¦â?¦â?¦ â?¦â
web.xml deployment descriptor - JSP-Servlet
web.xml deployment descriptor  Pls guide about how to write the web.xml file to deploy our web applications that uses JSP, by using tomcat... ... with JSP in tomcat.Thanks  Hi,Here is the code of web.xml:<?xml version
Advertisements
Deployment descriptor
Deployment descriptor  What is deployment descriptor ?   A deployment descriptor is an Extensible Markup Language (XML) text-based file... application and each of its modules has its own deployment descriptor. For example
Deployment Descriptor
applications, the deployment descriptor is called web.xml and resides in a WEB-INF... Deployment Descriptor       A deployment descriptor or DD in short is a configuration file
web.xml
web.xml  what is web.xml file..? explain its types..?   The web.xml file is important file for j2ee application. this file is also called the deployment descriptor. When you web application started the web server reads
EJB deployment descriptor
EJB deployment descriptor       Deployment descriptor is the file which tells the EJB server that which classes make.... it also indicates the behavior of one EJB with other. The deployment descriptor
Specifying an Authentication Mechanism in the Deployment Descriptor
In this section, you will learn how to specify an authentication mechanism in the deployment descriptor
Writing Deployment Descriptor of Stateless Session Bean
) and web.xml files. Application Deployment descriptor:ADS_TO_REPLACE_1 We need...Writing Deployment Descriptor of Stateless Session Bean...; In this section we will write the deployment descriptor
EJB deployment descriptor
EJB deployment descriptor       Deployment descriptor is the file which tells the EJB server... interface. it also indicates the behavior of one EJB with other. The deployment
web.xml
web xml  which url address is given in web.xml?   When using prefixes in XML, a so-called namespace for the prefix must be defined. The namespace is defined by the xmlns attribute in the start tag of an element
Match EJB roles with the corresponding description of the role's responsibilities, where the description may include deployment descriptor information.
may include deployment descriptor information. Prev Chapter 1... the description may include deployment descriptor information. There are 6...; and the bean's deployment descriptor. The deployment descriptor (DD
web.xml - servlet - Java Beginners
will be the second The element of a deployment descriptor is used to load.... The element is written in the deployment descriptor as follows: ServletName...web.xml - servlet  Hi All, In my web application, I have one
Given a security-related deployment descriptor tag, identify correct and incorrect statements and code related to that tag.
Given a security-related deployment descriptor tag, identify...; Given a security-related deployment descriptor tag, identify correct... by Application Assembler) in a deployment descriptor: <assembly
Identify correctly-implemented deployment descriptor elements for a CMP bean (including container-managed relationships).
deployment descriptor elements for a CMP bean (including container-managed... correctly-implemented deployment descriptor elements for a CMP bean (including container-managed relationships). The deployment descriptor is part
Identify correct and incorrect statements about the Application Assembler's responsibilities, including the use of deployment descriptor elements related to transactions and the identifica
responsibilities, including the use of deployment descriptor elements... responsibilities, including the use of deployment descriptor elements related... of the transaction attributes in the deployment descriptor
web.xml - XML
web.xml  Can you please help me to create web.xml I tried to create like this in editplus.. and enter ctrl + B It shows some error.... Is there any thing wrong with this web.xml otherwise please help me... Thanks
Identify correct and incorrect statements about the purpose and use of the deployment descriptor elements for environment entries, EJB references, and resource manager connection factory r
of the deployment descriptor elements for environment entries, EJB... to a particular deployment descriptor element. Prev Chapter 13...; The following illustrates an ejb-link in the deployment descriptor. The Application
Match the name with a description of purpose or functionality, for each of the following deployment descriptor elements: ejb-name, abstract-schema-name, ejb-relation, ejb-relat
, for each of the following deployment descriptor elements: ejb-name... or functionality, for each of the following deployment descriptor elements.... The deployment descriptor provides the following
Access web.xml init parameters
Access web.xml init parameters  How to access web.xml init parameters from java code
regarding web.xml - JSP-Servlet
regarding web.xml  I am the java beginner, please send the web.xml code and how to run a servlet for apache5.0.... my problem is in tomcat manager am getting the message 'fail' in web.xml  Hello,Please check the tomcat
Configure Js request in Web.xml
Configure Js request in Web.xml  Hi all, I have 1 basic doubt,suppose i have 2 jsp,1 servlet,1 web.xml file.i need to redirect 1 page via servlet with help of web.xml file.Here just i need to redirect to mainCtrl.java
tag library descriptor
tag library descriptor  i need types of tld ,uses of tld and example program for tag library descriptor
ModuleNotFoundError: No module named 'cron-descriptor'
ModuleNotFoundError: No module named 'cron-descriptor'  Hi, My... named 'cron-descriptor' How to remove the ModuleNotFoundError: No module named 'cron-descriptor' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'cron-descriptor'
ModuleNotFoundError: No module named 'cron-descriptor'  Hi, My... named 'cron-descriptor' How to remove the ModuleNotFoundError: No module named 'cron-descriptor' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ml-descriptor'
ModuleNotFoundError: No module named 'ml-descriptor'  Hi, My... 'ml-descriptor' How to remove the ModuleNotFoundError: No module named 'ml-descriptor' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Covariance-Descriptor'
ModuleNotFoundError: No module named 'Covariance-Descriptor'  Hi...: No module named 'Covariance-Descriptor' How to remove the ModuleNotFoundError: No module named 'Covariance-Descriptor' error? Thanks   Hi
ModuleNotFoundError: No module named 'cron-descriptor'
ModuleNotFoundError: No module named 'cron-descriptor'  Hi, My... named 'cron-descriptor' How to remove the ModuleNotFoundError: No module named 'cron-descriptor' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'descriptor-tools'
ModuleNotFoundError: No module named 'descriptor-tools'  Hi, My... named 'descriptor-tools' How to remove the ModuleNotFoundError: No module named 'descriptor-tools' error? Thanks   Hi, In your
Assembling web.xml from fragments
This section contains detailed description on assembling web.xml from web fragments with an example
How to Configure Spring in web.xml file ?
How to Configure Spring in web.xml file ?  How to Configure Spring in web.xml file ?   Hi you need to map the DispatcherServlet in web.xml as <servlet> <servlet-name>dispatcherServlet<
Cannot find tag library descriptor
Cannot find tag library descriptor  Cannot find tag library descriptor...? How to resolve in struts in eclipse
loacation of errorpage in web.xml for 404 error
loacation of errorpage in web.xml for 404 error   The webpage cannot be found HTTP 404 Most likely causes: â?¢There might be a typing error in the address. â?¢If you clicked on a link, it may be out of date. What you
ModuleNotFoundError: No module named 'invisibleroads-macros-descriptor'
ModuleNotFoundError: No module named 'invisibleroads-macros-descriptor' ...: ModuleNotFoundError: No module named 'invisibleroads-macros-descriptor' How to remove the ModuleNotFoundError: No module named 'invisibleroads-macros-descriptor'
Version of com.ariht>maven-assembly-descriptor dependency
List of Version of com.ariht>maven-assembly-descriptor dependency
Spring MVC JQuery Integration
problem by adding .js URL pattern mapping in deployment descriptor(web.xml...Spring MVC JQuery Integration In this section, you will learn about Spring MVC JQuery Integration by deployment descriptor. PROBLEM When you are including
Why <servlet-name> use in web.xml - JSP-Servlet
Why <servlet-name> use in web.xml  WHY DO WE USE THE <SERVLET-NAME>TAG IN WEB.XML APPLCATION   WHY DO WE USE THE <SERVLET-NAME>TAG IN WEB.XML APPLCATION AND HOW A simple program of using <servlet
How to use web.xml in Servlet 3.0
How to use web.xml in Servlet 3.0 In this tutorial you will learn how to use web.xml in Servlet 3.0. Here I am giving the simple example of a Servlet...; + id); } } web.xml <?xml version="1.0" encoding="UTF-8"
Maven Dependency maven-assembly-descriptor >> 0.9.2
You should include the dependency code given in this page to add Maven Dependency of com.ariht >> maven-assembly-descriptor version0.9.2 in your project
Maven Repository/Dependency: com.ariht | maven-assembly-descriptor
Maven Repository/Dependency of Group ID com.ariht and Artifact ID maven-assembly-descriptor. Latest version of com.ariht:maven-assembly-descriptor dependencies. # Version Release Date
without writing web.xml file we can write servlet program
without writing web.xml file we can write servlet program  Sir Morning... Sir I have one Question "without writing web.xml file we can write servlet program". if yes which way? if no why? but without use Annotation........ Plz
How to Send particular error to another page in Servlet from web.xml
How to Send particular error to another page in Servlet from web.xml  How to Send particular error to another page in Servlet from web.xml   Hi you can forward particular error from web.xml file as <error-page>
org.apache.maven - maven-plugin-descriptor version 2.0.9 Maven dependency. How to use maven-plugin-descriptor version 2.0.9 in pom.xml?
org.apache.maven  - Version 2.0.9 of maven-plugin-descriptor Maven...-descriptor in pom.xml? How to use maven-plugin-descriptor version 2.0.9... org.apache.maven  - Version 2.0.9 of maven-plugin-descriptor in project
Maven Repository/Dependency: org.apache.maven | maven-plugin-descriptor
Maven Repository/Dependency of Group ID org.apache.maven and Artifact ID maven-plugin-descriptor. Latest version of org.apache.maven:maven-plugin-descriptor dependencies. # Version Release Date
Create Tag Library Descriptor (TLD) File
Create Tag Library Descriptor (TLD) File  ..., we learn how to create library descriptor file in your project. Developers can... library descriptor file (TLD file) is used to describe the tag extensions and relate
J2EE Interview Questions -2
: What is Deployment Descriptor? Answer: A deployment descriptor is simply... descriptor describes the component deployment settings. Application servers reads the deployment descriptor to deploy the components contained in the deployment unit
deployment in eclipse
deployment in eclipse  How to run the web project in eclipse in resin server without using GUI hard deployment
How can I call a Servlet that is declare on web.xml with spring framework
How can I call a Servlet that is declare on web.xml with spring framework ... is declare on web.xml, but the spring dispacher don't find it so how I can make spring dispacher to call a servlet that is declare on my Web.xml here is my
Error !!! Can not find the tag library descriptor for "/WEB-INF/tlds/template.tld"
Error !!! Can not find the tag library descriptor for "/WEB-INF/tlds/template.tld"   I am not able to fix this problem. I tried different jar files, but no luck. Is there anything else apart from adding jar files that i can try
deployment error - XML
deployment error  hai, iam using sitemesh on spring framework, iam... web.xml entries to support spring and site mesh?? here is the error on my console and my web.xml ......... -------------------------------------- SEVERE: Error
Maven dependency for com.ariht - maven-assembly-descriptor version 0.9.2 is released. Learn to use maven-assembly-descriptor version 0.9.2 in Maven based Java projects
-descriptor released The developers of   com.ariht - maven-assembly-descriptor project have released the latest version of this library on 11 Aug 2014, the released version of  com.ariht - maven-assembly-descriptor library

Ads