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



Home Answers Viewqa JSP-Servlet web.xml deployment descriptor

Have Programming Question? Ask it here!
 
 
 


suhasini
web.xml deployment descriptor
3 Answer(s)      6 years and 6 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
Deployment
, When, When Not and How Deployment: Easy Installing with IzPack Applets
Access web.xml init parameters
Access web.xml init parameters  How to access web.xml init parameters from java code
tag library descriptor
tag library descriptor  i need types of tld ,uses of tld and example program for tag library descriptor
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
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
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
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<
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
Assembling web.xml from fragments
This section contains detailed description on assembling web.xml from web fragments with an example
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
deployment of servlet - JSP-Servlet
deployment of servlet  i have problem deploying theservlet , im posting the code please help me servlet class import javax.servlet.*; import... mapping - web.xml mine Beerselect mine
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 of your example - Struts
Deployment of your example  In your Struts2 tutorial, can you show how you would war it up so it can be deployed into JBOss? There seems to be a lot of unnecessary files in it, or am I mistaken
WebServices deployment in Weblogic - WebSevices
WebServices deployment in Weblogic  Hi, I want to create a service using Axis2 and deploy the service in Weblogic, along with my application war file. What is the common practice? Thanks in Advance, VJ
Struts 2.0- Deployment - Struts
1.5 Tomcat 6.0  Hi friend, Check your config of Web.xml.../struts/struts2/ Thanks   I placed correct web.xml only. For first time I
Deployment of JSF - Framework
Deployment of JSF   Hello, I am getting the following error while deploying the JSF application in JBOSS 4.0.0, I have followed all the steps...-INF\lib\jsf-impl.jar(com/sun/faces/taglib/jsf_core/ViewTag.class) class file
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
Website deployment on LAN
Website deployment on LAN  I have created a dynamic website in netbeans. Now i have to host the website on LAN so that by typing the URL of the project the users are able to view the content from their end. I have no idea
Deployment of your example - Struts
Deployment of your example  In your Struts2 tutorial, can you show how you would war it up so it can be deployed into JBOss? There seems to be a lot of unnecessary files in it, or am I mistaken?  Hi friend, Please
Deployment Error - Struts
Deployment Error  When I try to deploy application ?struts-examples-1.3.8.war? file in Tomcat 5.5 Web Server it is working fine. Whereas when I deploy the same web application in Weblogic8.1 Application Server, I am getting
Deployment on apache tomcat 7.0.14.0
Deployment on apache tomcat 7.0.14.0  Hi guys, Sorry but im not speeking english well. During developement , I deploy my app(with the context path : /EasyOrdo.) directly on netbeans, who use this tomcat version, integrated
Deployment - Java Beginners
Deployment   hi all Here is some problem which is often occured when i deployed a J2EE web application.When i deployed my application then this message is shown. D:\WorkSpace\Struts\WebApplication1\nbproject\build-impl.xml
Deployment on apache tomcat 7.0.14.0
Deployment on apache tomcat 7.0.14.0  Hi guys, Sorry but im not speeking english well. During developement , I deploy my app(with the context path : /EasyOrdo.) directly on netbeans, who use this tomcat version, integrated
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...); } } web.xml <?xml version="1.0" encoding="UTF-8"?> <web
website deployment - JSP-Servlet
was like changing the database string in web.xml file of the project and deploying... and not in web.xml file .So how wud I deploy multiple sites for each client having different
websphere deployment probllem - Java Beginners
websphere deployment probllem  How to deploy and run struts application using websphere application server v6.0 plz send the solution for this question
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
Weblogic Hot Deployment - Development process
Weblogic Hot Deployment  How to do auto-deployment on weblogic 9.2 ? Hi All, I am using Weblogic9.2 server. I am developing server side code.... So I wanted to set up hot deployment, which is called as auto-deployment
 

 

 

DMCA.com