Foros del Web » Programación para mayores de 30 ;) » Java »

Jsp, Bean y Servlet que no hace nada

Estas en el tema de Jsp, Bean y Servlet que no hace nada en el foro de Java en Foros del Web. Hola!! Estoy en netbeans con jsp's, servlets y beans. En este caso en concreto, el servlet ( servletCotizaciones ) crea una instancia del bean ( ...
  #1 (permalink)  
Antiguo 08/01/2009, 16:46
Avatar de Sandunguero  
Fecha de Ingreso: junio-2006
Mensajes: 56
Antigüedad: 17 años, 10 meses
Puntos: 0
Jsp, Bean y Servlet que no hace nada

Hola!!

Estoy en netbeans con jsp's, servlets y beans.

En este caso en concreto, el servlet (servletCotizaciones) crea una instancia del bean (beanHtmlCotizaciones) pasándole un String a su constructor. Desde el jsp pretendo llamar al metodo getHtml del bean para mostrar su valor en la página.

Pero algo falla, el servlet no hace nunca nada y devuelve siempre "null".


jsp:
Código PHP:
<jsp:useBean id="tablaCotizaciones" class="beans.beanHtmlCotizaciones" scope="session"/>
<%= 
tablaCotizaciones.getHtml() %> 

servletCotizaciones.java:
Código PHP:
public class servletCotizaciones extends HttpServlet {
    
    protected 
void processRequest(HttpServletRequest requestHttpServletResponse response)
    
throws ServletExceptionIOException {
       
        
response.setContentType("text/html;charset=UTF-8");
        
PrintWriter out response.getWriter();
        
out.println("------------");
        
System.out.println("+++++++++");
        
StringBuffer bufferHTML=new StringBuffer();
        
bufferHTML.append("HOLAAAAA");
        
beanHtmlCotizaciones tablaCotizaciones = new beanHtmlCotizaciones (bufferHTML.toString());

        
out.close();
    }

    
    protected 
void doGet(HttpServletRequest requestHttpServletResponse response)
    
throws ServletExceptionIOException {
        
processRequest(requestresponse);
    }
    

    protected 
void doPost(HttpServletRequest requestHttpServletResponse response)
    
throws ServletExceptionIOException {
        
processRequest(requestresponse);
    }



beanHtmlCotizaciones.java:
Código PHP:
package beans;


public class 
beanHtmlCotizaciones implements java.io.Serializable{
    
    private 
String html;
    
    public 
beanHtmlCotizaciones() {}
    
    public 
beanHtmlCotizaciones(String html){
        
setHtml(html);
    }
    
   public 
String getHtml (){
       return 
this.html;
   }
   
   public 
void setHtml (String html) {
        
this.html=html;
   }
    


El servlet no hace nada, ni muestra esos caracteres ni nada. Tampoco da ningún error por ningún sitio.

¿Alguna pequeña ayuda por favor?
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:09.