PDA

View Full Version : Jsp e Servlet Java - Pagina Bianca


dafcon
20-12-2014, 11:22
Salve ho un prblema con jsp e Servlet Java. Quando avvio Eclipse Luna con Apache Tomcat 7.0 mi visualizza una pagina bianca. Di seguito vi posto il web.xml, la Servlet e la Home.jsp. Qualcuno puņ darmi suggerimenti? Grazie in anticipo

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>InformatizzazioneEnergiaPrima</display-name>
<servlet>
<servlet-name>Log</servlet-name>
<servlet-class>controllore.Log</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Log</servlet-name>
<url-pattern>/home.jsp</url-pattern>
</servlet-mapping>
</web-app>


home.jsp

<%@ 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>Insert title here</title>
</head>
<body>
<form action="Log" method="post">
<table>
<tr>
<td>Username</td>
<td><input type="text" name="username"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"/></td>
</tr>
<tr>
<td><input type="submit" value="Login"/></td>
</tr>
</table>
</form>
</body>
</html>


Servlet


package controllore;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class Log
*/
@WebServlet("/Log")
public class Log extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public Log() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
PrintWriter out=response.getWriter();
out.println("Welcome");
out.flush();
}

}