how to send an object from a servlet to a jsp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mosis
    New Member
    • Aug 2010
    • 1

    #1

    how to send an object from a servlet to a jsp

    I really need help ,
    i am working on an application with netbeans and servlets.
    I have a form in which i give the id then select a table in which i will go and search the id to the oracle database.


    i am trying to send my objet to the jsp file from the servlet.
    --------------------------------------------
    this is the way i did

    //recherche sur la table BASE_NGHLR new instance pour acceder a la methode recherche(id)
    BASE_NGHLR base=new BASE_NGHLR();
    //instance pour recuperer le resultat de la recherche (qui retourne un objet)

    base=base.reche rche(msisdn);
    //envoi a la page res_recherche.j sp
    request.setAttr ibute("BASE_NGH LR",base.getIms i());
    RequestDispatch er res=getServletC ontext().getReq uestDispatcher( "/res_recherche.j sp");
    res.forward(req uest,response);
    ------------------------------------------------------

    this is my error
    ATTENTION: ApplicationDisp atcher[/tutoj2ee] PWC1231: Servlet.service () for servlet jsp threw exception
    java.lang.NullP ointerException
    at org.apache.jsp. res_005frecherc he_jsp._jspServ ice(res_005frec herche_jsp.java from :125)
    at org.apache.jasp er.runtime.Http JspBase.service (HttpJspBase.ja va:109)
    at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:847)
    at org.apache.jasp er.servlet.JspS ervletWrapper.s ervice(JspServl etWrapper.java: 406)
    at org.apache.jasp er.servlet.JspS ervlet.serviceJ spFile(JspServl et.java:483)
    at org.apache.jasp er.servlet.JspS ervlet.service( JspServlet.java :373)
    at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:847)
    at org.apache.cata lina.core.Stand ardWrapper.serv ice(StandardWra pper.java:1523)
    at org.apache.cata lina.core.Appli cationDispatche r.doInvoke(Appl icationDispatch er.java:802)
    at org.apache.cata lina.core.Appli cationDispatche r.invoke(Applic ationDispatcher .java:664)
    at org.apache.cata lina.core.Appli cationDispatche r.processReques t(ApplicationDi spatcher.java:4 97)
    at org.apache.cata lina.core.Appli cationDispatche r.doDispatch(Ap plicationDispat cher.java:468)
    at org.apache.cata lina.core.Appli cationDispatche r.dispatch(Appl icationDispatch er.java:364)
    at org.apache.cata lina.core.Appli cationDispatche r.forward(Appli cationDispatche r.java:314)
    at STIC3.connectio nServlet.doGet( connectionServl et.java:207)
    at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:734)
    at javax.servlet.h ttp.HttpServlet .service(HttpSe rvlet.java:847)
    at org.apache.cata lina.core.Stand ardWrapper.serv ice(StandardWra pper.java:1523)
    at .Thread.run(Thr ead.java:619)
Working...