Pagina 6 di 6 primaprima ... 4 5 6
Visualizzazione dei risultati da 51 a 56 su 56
  1. #51
    allora l'errore non me lo da più solo ke mi dice impossibile visualizzare la pagina sia quando faccio send dal form sia quando faccio http://localhost:8080/ITemRecommender/Login
    il percorso ke mi esce quando faccio send è C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ITemRecommender\Login
    e nella pagina .htm ho messo <FORM id="form_user_registration" METHOD="post" ACTION="Login">
    il web.xml è sempre l'ultimo ke ho postato
    ora perkè mi dice impossibile visualizzare la pagina? da cosa è dovuto?
    ps:grazie mille per avermi fatto risolvere l'errore 404 (era diventato il mio incubo heheh)

  2. #52
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    906
    La pagina dove sta la form, la apri da browser con l'indirizzo http://localhost:8080/ITemRecommender/NomePagina
    Perche' dall'indirizzo che c'e' dopo la form sembra quasi che tu la apra con il percorso del tuo computer.
    C'e' scritto "Impossibile visualizzare la pagina" e basta o c'e' scritto altro?
    Nel log ti da qualche nuovo errore?

  3. #53
    ora mi partono solo ke mi da un altro errore e a quanto pare perkè non trova un percorso di un file ke la servlet mi deve creare
    giusto?

    codice:
    HTTP Status 500 - 
    
    --------------------------------------------------------------------------------
    
    type Exception report
    
    message 
    
    description The server encountered an internal error () that prevented it from fulfilling this request.
    
    exception 
    
    java.io.IOException: Impossibile trovare il percorso specificato
    	java.io.WinNTFileSystem.createFileExclusively(Native Method)
    	java.io.File.createNewFile(Unknown Source)
    	projectservlet.RegistrationAndSendEmail.doPost(RegistrationAndSendEmail.java:178)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.
    (devo aprire un'altra discussione?)

  4. #54
    questo è il contenuto della servlet relativa alla registrazione di un utente
    codice:
    /**
     * 
     */
    package projectservlet;
    
    /**
     * @(#)RegistrationAndSendEmail.java
     *
     *
     * @author Raffaella
     * @version 1.00 2007/4/24
     */
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.io.File;
    import java.util.*;
    import java.text.*;
    import org.jdom.*;
    import org.jdom.input.SAXBuilder;
    import org.jdom.output.XMLOutputter;
    import java.util.Iterator;
    import java.util.List;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    				
    public class RegistrationAndSendEmail extends HttpServlet{
    
    	Document documento = null;
    	Element elementoRegistrati = null;
    	String fullname,email,password_inviata,username_inviato;	
    	
    	public void aggiungiRegistrato(){
    		Element registrato = new Element("registrated");
    		Element element_nome = new Element("fullname");
    		Element element_email = new Element("email");
    		
    		element_nome.setText(fullname);
    		element_email.setText(email);
    		
    		registrato.addContent(element_nome);
    		registrato.addContent(element_email);
    		registrato.setAttribute("password",password_inviata);
    		registrato.setAttribute("username",username_inviato);	
    		elementoRegistrati.addContent(registrato);
    	}
    	
    	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
    		
    		StringBuffer buf = new StringBuffer();
    		response.setContentType("text/html");
    		PrintWriter responseOutput = response.getWriter();
    		buf.append("<html><head></head><body><table border=\"1\" width=\"40%\" align=\"center\"><tbody><tr>");
    		String controllo = new String("ok");
    		//RECUPERO LE INFORMAZIONI INVIATE DAL FORM
    		fullname = request.getParameter("fullname");
    		email = request.getParameter("email");
    		
    		password_inviata = request.getParameter("password");
    		username_inviato = request.getParameter("username");
    		if ((fullname != "") && (email != "") && (password_inviata != "") && (username_inviato != "")){		
    			//CONTROLLO SE ESISTE GIA' UN FILE .XML CHE SI CHIAMA REGISTRATED
    			String path = new String ("../webapps/ITemRecommender/xml/registrated.xml");
    			File file = new File(path);
    			//SE IL FILE NON ESISTE LO CREO E GLI AGGIUNGO L'ELEMENTO RADICE IL PRIMO REGISTRATO
    			if (!file.exists()){
    				file.createNewFile();
    				elementoRegistrati = new Element("registrated");
    				//AGGIUNGO IL REGISTARTO CHE RISULTA IL PRIMO DATO CHE IL FILE REGISTRATI.XML NON ESISTEVA
    				aggiungiRegistrato();
    				//SCRIVO IL DOCUMENT NEL FILE		
    				documento = new Document(elementoRegistrati);
    				XMLOutputter xmlOutputter = new XMLOutputter();
    				try{
       					FileOutputStream fileOutputStream = new FileOutputStream(new File(path)); 
       					xmlOutputter.output(documento, fileOutputStream);
    					buf.append("<td align=\"center\">Thank you for registering, " + username_inviato + ". An email has been dispatched to " + email + " with details on how to activate your account.
    
    <a href=\"Recommendations.htm\">Proceed</a></p></td>");
     				}
    	 			catch (FileNotFoundException ex){
       					System.err.println(ex);
     				}
    	 			catch (IOException ex){
       					System.err.println(ex);
     				}
    			}
    			else{
    				//SE IL FILE ESISTE LO CARICO IN MEMORIA
     				SAXBuilder saxBuilder = new SAXBuilder();
    				try{
       					documento = saxBuilder.build(new File(path)); 
     				}
     				catch (JDOMException ex){
       					System.err.println(ex);
    				}
    	 			catch (IOException ex){
       					System.err.println(ex);
     				}					
    				//POI UNA VOLTA CARICATO CONTROLLO CHE NON CI SIA GIA' UN REGISTRATO CON TALE LOGIN E SE NON C'è INSERISCO IL NUOVO 
    				//REGISTRATO ALTRIMENTI DICO DI CAMBIARE LOGIN
    				elementoRegistrati = documento.getRootElement(); 
    				List lista_registrati = elementoRegistrati.getChildren();
    				// ottengo un iteratore alla lista chiamando il metodo iterator() di Collection (essendo una list una collection) 
     				Iterator iteratore = lista_registrati.iterator();
    				while (iteratore.hasNext())
    	 			{ 
    	   				// ottengo l'elemento corrente chiamando next() sull'iteratore 
    	   				Element registrato_corrente = (Element)iteratore.next(); 
    					String username = registrato_corrente.getAttributeValue("username");
    					String password = registrato_corrente.getAttributeValue("password");
    					if (password_inviata.equals(password)){
    						buf.append("<td>Password existing, choose a different password.</td>");
    						controllo = new String("ko");
    						break;
    					}
    	 			}
    				if (controllo.equals("ok")){
    					//RISCRIVO L'INTERO DOCUMENTO NEL FILE XML DOPO AVER AGGIUNTO IL REGISTRATO
    					aggiungiRegistrato();
    					XMLOutputter xmlOutputter = new XMLOutputter();
    	 					    			try{
    	   					FileOutputStream fileOutputStream = new FileOutputStream(new File(path)); 
    	   					xmlOutputter.output(documento, fileOutputStream);
    						buf.append("<td>Registration Successfull
    
    <a href=\"Recommendations.htm\">Proceed</a></p></td>");
    	 				}
    			 		catch (FileNotFoundException ex){
    	   					System.err.println(ex);
    	 				}
    			 		catch (IOException ex){
    	   					System.err.println(ex);
    	 				}
    				}			
    			}
    		}
    		else{
    			buf.append("<td>Missing informations, fields with * are compulsory</td>");
    		}
    		buf.append("</tr></tbody></table></body></html>");
    		responseOutput.println(buf.toString());
    		responseOutput.close();
        }
        
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            doPost(request, response);
        }
    }
    sarebbe sbagliato questo percorso String path = new String ("../webapps/ITemRecommender/xml/registrated.xml"); ?

  5. #55
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    906
    Prova a commentare tutto il pezzo successivo a
    codice:
    String path = new String ("../webapps/ITemRecommender/xml/registrated.xml");
    File file = new File(path);
    fino a
    codice:
    buf.append("</tr></tbody></table></body></html>");
    responseOutput.println(buf.toString());
    responseOutput.close();
    e nel mezzo stampa file.getAbsolutePath per vedere se te lo cerca nella posizione corretta.

  6. #56
    ho risolto fungono le servlet (non so come ho solo avviato la pagina index)
    grazie mille simo davvero molto gentile senza di te (e agli altri naturalmente) non ce l'avrei mai fatta
    graziee

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.