Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Recensione Google Pixel 10a, si migliora poco ma è sempre un'ottima scelta
Recensione Google Pixel 10a, si migliora poco ma è sempre un'ottima scelta
Google ha appena rinnovato la sua celebre serie A con il Pixel 10a, lo smartphone della serie più conveniente se consideriamo il rapporto tra costo e prestazioni. Con il chip Tensor G4, un design raffinato soprattutto sul retro e l'integrazione profonda di Gemini, il colosso di Mountain View promette un'esperienza premium a un prezzo accessibile. E il retro non ha nessuno scalino
6G, da rete che trasporta dati a rete intelligente: Qualcomm accelera al MWC 2026
6G, da rete che trasporta dati a rete intelligente: Qualcomm accelera al MWC 2026
Al MWC Qualcomm annuncia una coalizione industriale per lanciare il 6G entro il 2029 e introduce agenti IA per la gestione autonoma della RAN. Ericsson, presente sul palco, conferma la direzione: le reti del futuro saranno IA-native fin dalla progettazione
CHUWI CoreBook Air alla prova: design premium, buona autonomia e qualche compromesso
CHUWI CoreBook Air alla prova: design premium, buona autonomia e qualche compromesso
CHUWI CoreBook Air è un ultraleggero da 1 kg con Ryzen 5 6600H, display 14" 16:10 e 16 GB LPDDR5. Offre buona portabilità, autonomia discreta e costruzione in alluminio, ma storage PCIe 3.0 e RAM saldata limitano l'espandibilità. A 549 euro sfida brand più noti nella stessa fascia di mercato.
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 29-05-2005, 19:30   #1
_Nirvana_
Junior Member
 
Iscritto dal: May 2005
Messaggi: 1
Errore con STRUTS!

Salve a tutti.
Da poco ho iniziato a programmare in j2ee con struts, ma è da un bel paio di giorni che sto impazzendo su un login che non ne vuole proprio sapere di funzionare! Sto impazzendo!!! Sono sull'orlo di una crisi di nervi!

Per chiarezza vi posto gran parte dei file interessati.
Io non sono riuscito a trovare errori...

L'errore riscontrato è:

HTTP Status 404 - Servlet action is not available
---------------------------------------------------------

type Status report

message Servlet action is not available

description The requested resource (Servlet action is not available) is not available.


Apache Tomcat/5.5.7
---------------------------------------------------------



La parte di configurazione di Struts-config.xml
---------------------------------------------------------
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<!--
Struts configuration file
--><struts-config>

<!-- ============================================ Data Source Configuration -->

<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="org.gjt.mm.mysql.Driver" />
<set-property property="url" value="jdbc:mysql://localhost:3306/SiteLabLing" />
<set-property property="username" value="root" />
<set-property property="password" value="admin" />
<set-property property="maxActive" value="10" />
<set-property property="maxWait" value="5000" />
<set-property property="defaultAutoCommit" value="false" />
<set-property property="defaultReadOnly" value="false" />
<set-property property="validationQuery" value="SELECT COUNT(*) FROM market" />
</data-source>
</data-sources>


<!-- ================================================ Form Bean Definitions -->

<form-beans>
<!-- Login form bean -->
<form-bean name="loginForm"
type="org.apache.struts.webapp.login.LoginForm" />
<form-bean name="uploadForm"
type="org.apache.struts.webapp.file.UploadForm" />
<form-bean name="downloadForm"
type="org.apache.struts.webapp.file.DownloadForm" />
<form-bean name="listDocForm"
type="org.apache.struts.webapp.file.ListDocForm" />
<form-bean name="emailForm"
type="org.apache.struts.webapp.email.EmailForm" />

</form-beans>



<!-- sample form bean descriptor for an ActionForm
<form-bean
name="inputForm"
type="app.InputForm"/>
end sample -->

<!-- sample form bean descriptor for a DynaActionForm
<form-bean
name="logonForm"
type="org.apache.struts.action.DynaActionForm">
<form-property
name="username"
type="java.lang.String"/>
<form-property
name="password"
type="java.lang.String"/>
</form-bean>
end sample -->

<!-- ========================================= Global Exception Definitions -->

<global-exceptions>
<exception type="" key="global.error.invalidLogin" path="/pages/Login.jsp" />
<!-- sample exception handler
<exception
key="expired.password"
type="app.ExpiredPasswordException"
path="/changePassword.jsp"/>
end sample -->
</global-exceptions>


<!-- =========================================== Global Forward Definitions -->

<global-forwards>
<forward name="welcome" path="/Welcome.do" redirect="true" />
<forward name="login" path="/Login.do" redirect="true" />
<forward name="systemFailure" path="/SystemError.do" redirect="true" />
<forward name="sessionTimeOut" path="/SessionTimeOut.do" />
</global-forwards>


<!-- =========================================== Action Mapping Definitions -->

<action-mappings>

<!-- In action l'attributo:
path= rappresenta il nome della action
name= rappresenta il nome della form -> uguale al form-bean-->

<action path="/welcome"
forward="/pages/Welcome.jsp" />

<!-- Per visualizzare la pagina di login -->
<action path="/login"
forward="pages/Login.jsp"/>

<!-- Per processare il login -->
<action path= "/submitLogin"
type= "org.apache.struts.webapp.login.LoginAction"
name= "loginForm"
scope= "request"
validate= "true"
input= "/pages/Login.jsp">
<forward name="errorDb" path="/pages/Login.jsp" />
<forward name="errorLogin" path="/pages/Login.jsp" />
<forward name="pagStud" path="/pages/pageStud.jsp" />
<forward name="pagProf" path="/pages/pageProf.jsp" />
</action>





Il file Login.jsp
---------------------------------------------------------

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>

<%@ page contentType="text/html"%>
<%@ page pageEncoding="UTF-8"%>

<!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=UTF-8">
<link href="style.css" rel="stylesheet" type="text/css">
<title>Login</title>
</head>

<body>
<center>
<font class="title"><b>Login Page</b></font>
<br/><br/>
<html:errors/>
<html:form action="submitLogin">
<table>
<tr>
<td align="right">Nome:</td>
<td align="left"><html:text
property="nome"
size="18" /></td>
</tr>
<tr>
<td align="right">Password:</td>
<td align="left"><html: password
property="password"
size="18"
maxlength="18"
redisplay="false" /></td>
</tr>
<tr>
<td align="right">
<html:submit>Login</html:submit>
</td>
<td align="left">
<html:reset>Cancella</html:reset>
</td>
</tr>
</table>
</html:form>
</font>
</center>
</body>
</html>




Il file LoginAction
---------------------------------------------------------

package org.apache.struts.webapp.login;

import java.io.*;
import java.sql.*;
import java.lang.*;
import javax.servlet.http.*;

import org.apache.struts.action.*;

//==========================================
// ...paginaStruts
//==========================================


public final class LoginAction extends Action {

public ActionForward
execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{

if (form instanceof LoginForm) {

//==========================================
// Aquisizione da Form
//==========================================

LoginForm loginForm = (LoginForm) form;

// -------> Aquisizione parametri dal form

String nome = loginForm.getNome();
String password = loginForm.getPassword();

//==========================================
// Provvediamo alla connesione col Database.
//==========================================

javax.sql.DataSource dataSource;
java.sql.Connection myConnection=null;

try {
dataSource = getDataSource(request);
myConnection = dataSource.getConnection();

//==========================================
// Interroghiamo il Database...
//==========================================

Statement stm = myConnection.createStatement();

// Interrogo il DBMS mediante una query SQL.
// Creo una tabella e vi inserisco dei dati
// Stampo su schermo la tabella

ResultSet resultset = stm.executeQuery(
"SELECT Id, Nome, Password, Ident FROM Studenti, Professori");
// Scorro i risultati.
while (resultset.next()) {
String id = resultset.getString(1);
String nomeR = resultset.getString(2);
String passwordR = resultset.getString(3);
String ident = resultset.getString(4);

if((nomeR==nome)&&(passwordR==password)){
if(ident=="stud"){

//==========================================
// Blocco sessione_inizio
//
// Invalidiamo la sessione se esiste già
HttpSession session = request.getSession(false);
if(session != null) {
session.invalidate();
}

// Creiamo una sessione per questo utente
session = request.getSession(true);

// Setto gli attributi della sessione
// si tratta di coppie nome/valore
session.setAttribute("ID", id );
session.setAttribute("NOME", nome );
session.setAttribute("PASSWORD", password );
session.setAttribute("IDENT", ident );
// Blocco sessione_fine
//==========================================

return mapping.findForward("pagStud");
}
if(ident=="prof"){

//==========================================
// Blocco sessione_inizio
//
// Invalidiamo la sessione se esiste già
HttpSession session = request.getSession(false);
if(session != null) {
session.invalidate();
}

// Creiamo una sessione per questo utente
session = request.getSession(true);

// Store the UserView into the session and return
session.setAttribute( nome, password );
// Blocco sessione_fine
//==========================================

return mapping.findForward("pagProf");
}
}
else{
// errore: non si trova nelle tabelle
// -> si
return mapping.findForward("errorLogin");
}
}

//==========================================
// Per eventuali eccezioni...
//==========================================

} catch (SQLException e) {
// getServlet().log("Connection.process", sqle);
return mapping.findForward("errorDb");
}

finally {
//enclose this in a finally block to make
//sure the connection is closed
try {
myConnection.close();
} catch (SQLException e) {
// connessione terminata
// getServlet().log("Connection.close", e);
return mapping.findForward("errorDb");
}
}

return mapping.findForward("errorLogin");
}

return null;
}

}



Il file LoginForm
---------------------------------------------------------

package org.apache.struts.webapp.login;

import org.apache.struts.action.*;
import javax.servlet.http.*;

public final class LoginForm extends ActionForm {


// --------------------------------------------------- Instance Variables
/**
* An example String property.
*/
private String password = null;
private String nome = null;
// ----------------------------------------------------------- Properties
/**
* Return the password String.
*/
public String getPassword() {
return (this.password);
}


/**
* Set the password String.
* @param password The new password String.
*/
public void setPassword(String password) {
this.password = password;
}

// ---------------------------------------> passiamo al nome

/**
* Return the nome String.
*/
public String getNome() {
return (this.nome);
}

/**
* Set the nome String.
* @param nome The new nome String.
*/
public void setNome(String nome) {
this.nome = nome;
}


// --------------------------------------------> validazione


public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request){

ActionErrors errors=new ActionErrors();

if((nome==null)||(nome.length()<1))
errors.add("nome", new ActionError("errors.name.obblig"));

if((password==null)||(password.length()<1))
errors.add("password", new ActionError("errors.password.obblig"));

return errors;
}

}





Aiutatemi!
Ho provato decine e decine di volte!
Ho chiesto a diversi forum, ma nessuno è riuscito a dirmi che errore c'è nel codice!

Grazie.

Ultima modifica di _Nirvana_ : 29-05-2005 alle 19:33.
_Nirvana_ è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Recensione Google Pixel 10a, si migliora poco ma è sempre un'ottima scelta Recensione Google Pixel 10a, si migliora poco ma...
6G, da rete che trasporta dati a rete intelligente: Qualcomm accelera al MWC 2026 6G, da rete che trasporta dati a rete intelligen...
CHUWI CoreBook Air alla prova: design premium, buona autonomia e qualche compromesso CHUWI CoreBook Air alla prova: design premium, b...
Roborock Saros 20: il robot preciso e molto sottile Roborock Saros 20: il robot preciso e molto sott...
ASUS ROG Kithara: quando HIFIMAN incontra il gaming con driver planari da 100mm ASUS ROG Kithara: quando HIFIMAN incontra il gam...
Rocket Lab ha posticipato il lancio del ...
Dalla missione Artemis IV il razzo spazi...
Una delle sonde europee di ESA Proba-3 h...
Un modder fa girare Linux su PS5: GTA V ...
MacBook Neo: nessuna sorpresa nei primi ...
La serie POCO X8 Pro è pronta al ...
Smartphone: 2026 difficile per il mercat...
Star Wars: Knights of the Old Republic R...
Huang, NVIDIA: OpenClaw ha realizzato in...
Annunciano il recupero di 4,8 milioni di...
Oggi degli ottimi auricolari Sony con ca...
Muffa in casa? Questo deumidificatore da...
Sonos Era 100: il punto d'ingresso per u...
"Non stiamo sostituendo nessuno con...
Tutti i robot in offerta ora: prezzi bas...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 06:50.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v