Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet web.xml deployment descriptor
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


suhasini
web.xml deployment descriptor
3 Answer(s)      6 years and 9 months ago
Posted in : JSP-Servlet


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


Advertisement
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
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: We need the following...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  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
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
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... attributes in the deployment descriptor. The updatePhoneNumber
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
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
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
tag library descriptor
tag library descriptor  i need types of tld ,uses of tld and example program for tag library descriptor
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
deployment in eclipse
deployment in eclipse  How to run the web project in eclipse in resin server without using GUI hard deployment
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
Cannot find tag library descriptor
Cannot find tag library descriptor  Cannot find tag library descriptor...? How to resolve in struts in eclipse
Spring MVC JQuery Integration
URL pattern mapping in deployment descriptor(web.xml) as follows : <...Spring MVC JQuery Integration In this section, you will learn about Spring MVC JQuery Integration by deployment descriptor. PROBLEM When you are including
deployment error
deployment error  when i deployed my .ear file into the jboss4.2.3 ga it shows this exception in server log any body please help me,thanks in advance error is : 012-08-22 15:19:41,068 DEBUG
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<
Assembling web.xml from fragments
This section contains detailed description on assembling web.xml from web fragments with an example
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
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
JavaFX deployment in Jboss
JavaFX deployment in Jboss  Hi, How to deploy javafx application into JBoss
 

 

 

DMCA.com