HTTP Status 500 - Internal Server Error.

mark89

Nuovo Utente
27 Mar 2021
2
0
1
Salve sto tentando di realizzare questa piccola applicazione web:

1) Creare un menu che tramite iperlink permette la navigazione su due pagine jsp:
Inserisci Cantante
Modifica Cantante
3) la pagina esitoModifica.jsp consente di visualizzare semplicemente: “Sito in costruzione”
4) La pagina insCantante.jsp “chiama la ServletController e quest’ultima stampa i dati tramite
la pagina jsp “esitoInserimento”.
In ques’ultima vengono visualizzati i dati del cantante inseriti e un messaggio: “dati inseriti correttamente”.

In verità, quando inserisco i dati di un cantante nel form ed invio, esce sulla pagina web l'errore:
HTTP Status 500 - Internal Server Error.

Questo è il codice del form per l'inserimento del cantante:
Codice:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Inserimento cantante</title>
</head>
<body>
<center>
<h1>Inserimento cantante</h1>
<p>
<form name="inserimento" method="get" action="./ServletController?azione=3">
<p>Inserire il nome del cantante: <input  type="text" name="nome" size="30">
<p>Inserire il cognome del cantante: <input  type="text" name="cognome" size="30">
<p> Cliccare sul tasto INVIA per trasmettere i dati, oppure sul tasto RESET per anullare i valori dei campi
<p><input type="submit" value="invia" name="botton1">
<input type="reset" value="cancella" name="botton2">
</form>
</center>
</body>
</html>

Questo invece e il codice della servlet:
Codice:
package pkg1;


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;
import javax.servlet.RequestDispatcher;

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

    final int INSERIMENTO = 1;
    final int MODIFICA= 2;
    final int ESITO_INSERIMENTO=3;

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

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {


        RequestDispatcher rd;
        String action = request.getParameter("azione");

        int azione = Integer.valueOf(action).intValue();
       
        if(azione==INSERIMENTO)
        {
             rd=request.getRequestDispatcher("insCantante.jsp");
        rd.forward(request, response);
        }

        else if(azione==MODIFICA)
        {
             rd=request.getRequestDispatcher("esitoModifica.jsp");
        rd.forward(request, response);
        }

        else if(azione==ESITO_INSERIMENTO)
        {
            String nomeCantante=request.getParameter("nome");
            request.setAttribute("nome", nomeCantante);
            String cognomeCantante=request.getParameter("cognome");
            request.setAttribute("cognome", cognomeCantante);
           
            rd=request.getRequestDispatcher("esitoInserimento.jsp");
                rd.forward(request, response);
        }
               
        }
   

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

}

E questo e il codice della pagina jsp esitoInserimento:
Codice:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Esito inserimento.</title>
</head>
<body>
<center>
<% String nomeCantante=(String)request.getAttribute("nome");%>
<%String cognomeCantante=(String)request.getAttribute("cognome");%>
<h1>Dati inseriti correttamente:</h1>
<h2><%System.out.println(nomeCantante+" "+cognomeCantante); %></h2>
</center>
</body>
</html>

Non ho capito dove ho sbagliato.
 

Allegati

  • 1617811049688.png
    1617811049688.png
    40,6 KB · Visite: 170
Discussioni simili
Autore Titolo Forum Risposte Data
F firefox problema http Linux e Software 0
A errore http://datatables.net/tn/7 PHP 4
L Richieste HTTP get post PHP 1
M [PHP] Modi per fare redirect 301 da http a https PHP 12
B [Java] Paginazione in risposta HTTP Java 0
P Migrazione sito da http a https per rispettare linee guida google SEO e Posizionamento 12
giorgiolovecchio [WordPress] Risorsa http invalida sicurezza sito WordPress 2
Z HTTP ERROR 500 - La pagina non funziona - Joomla! Joomla 0
E [IIS] Reindirizzare richieste esterna http su https Web Server 0
MarcoGrazia Ricerca dell'esistenza del protocollo ( http | https ) in un url Javascript 2
W scambio banner sito per adulti http://massaggicinesi.tk/ Offerte e Richieste di scambio links 0
C Meta tag http-equiv="X-UA-Compatible" errore validatore w3c HTML e CSS 3
A conflitto http/https con google sites Javascript 1
Eruyomon http://studiosergipartners.it/ Presenta il tuo Sito 0
novello88 HTTP Basic Auth su Altervista PHP 0
E HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this director Hosting 10
D Centralizzare Http da più server via ssh Linux e Software 1
Z Esercizio HTTP su SSL Apache 1
M Come verificare accesso ad area http auth basic? PHP 7
V HTTP Long polling Ajax 7
E http request - POST o PUT? PHP 1
M Verifica HTTP o HTTPS PHP 1
C [RISOLTO]Numeri random al termine di un link http Javascript 27
A HTTP Error 403.14 - Forbidden Hosting 4
B Scaricare file xml dopo autenticazione http PHP 1
D richieste http PHP 1
A Alternativa al <meta http-equiv="refresh" content="5;url=code.php" > HTML e CSS 5
L Tabella con rappresentazione corretta di tutti i campi e dei link HTTP . Ciclo for? PHP 5
M Volevo creare un servizio come http://www.destructingmessage.com/ PHP 2
D http://www.dedalo.byethost6.com/ Dedalo intelligenza condivisa Presenta il tuo Sito 0
M http://cryptoncomputer.altervista.org/webphp.php Presenta il tuo Sito 2
M Instantempo! http://instantempo.mattyfog.com Presenta il tuo Sito 0
C Professionista I.T. - Informatico free lance - http://www.malorgio.it Presenta il tuo Sito 0
D Problema DOPPIA richiesta HTTP Ajax 0
I 505 HTTP Version Not Supported PHP 5
T IIS attivo ma errore su http://localhost Classic ASP 1
catellostefano [URGENTISSIMO] si è verificato un errore in http server Apache 2
JellyBelly GET tramite file_get_contents a un url esterno http PHP 2
M Ajax http request refresh problem Ajax 0
N URGENTE "script src=http://www.bnradd.mobi/ngg.js" Database 0
S http://www.eventi-nightanday.com/ Presenta il tuo Sito 0
daviduccio IIS6 e PHP - Intestazioni HTTP - Web Server 5
G http://www.calcioealtro.netsons.org Presenta il tuo Sito 1
G http://wwe.nude.divas.forumcommunity.net/ Presenta il tuo Sito 0
virus.jack Http://virusjack.altervista.org Presenta il tuo Sito 0
V http://viviana.altervista.org Presenta il tuo Sito 3
M http://www.securitysite.helloweb.eu Presenta il tuo Sito 0
L http://www.securelook-mail.biz/ - Directory Free Presenta il tuo Sito 0
D nokia forum - il forum dedicato ai nokia e non solo: http://nokia.theforumx.net/ Presenta il tuo Sito 1
R HTTP Error 404 - File or directory not found. Classic ASP 1

Discussioni simili