Deja un comentario

Hola Mundo JSP

Por: Raul Macias

Ejemplo de como crear una aplicación en apache tomcat 7.0, sin ningún IDE.

  1. Crear la carpeta holamundo en webapps.
  2. Crear sub carpeta WEB-INF dentro de holamundo.
  3. Crear archivo index.jsp en la carpeta holamundo.
  4. Crear archivo web.xml dentro de la carpeta WEB-INF.
  5. Navegar a http://localhost:8080/holamundo y voilà el servidor esta sirviendo la pagina.

Como observación cuando estoy creando desde Eclipse o NetBeans una aplicación utilizando Tomcat 7.0 de este tipo, tengo que modificar el archivo web.xml en su linea web-app remplazando por la siguiente:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
 version="3.0"
 metadata-complete="true">

A continuación dejo los códigos de las paginas:

Pagina index.jsp

</pre>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Pagina Hola Mundo</title>
</head>
<body>
Hola Mundo!
</body>
</html>
<pre>

Archivo web.xml

</pre>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements. See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
 version="3.0"
 metadata-complete="true">

<display-name>holamundo</display-name>
 <description>
 Hola Mundo
 </description>
</web-app>
<pre>

Los archivos se pueden descargar de aqui: holamundo.zip

Por: Raul Macias

Deja un comentario

Fill in your details below or click an icon to log in:

Logo de WordPress.com

You are commenting using your WordPress.com account. Log Out / Cambiar )

Twitter picture

You are commenting using your Twitter account. Log Out / Cambiar )

Facebook photo

You are commenting using your Facebook account. Log Out / Cambiar )

Connecting to %s

Seguir

Get every new post delivered to your Inbox.