You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ernst Bekker <er...@isservices.co.za> on 2002/03/20 09:22:11 UTC
NEWBIE: Passing object from Servlet to JSP with session?
Hi,
I am running TomCat 4, and am attempting to forward an object to a JSP from
a servlet.
I have set up a new directory under .../webapps and the class files for both
the servlet
and the class of which I am trying to send an instance of are in .../
webapps/newdir/WEB-INF/classes.
The JSP file is in .../webapps/newdir.
It seems that the servlet forwards the request but the JSP coughs up the
following exception:
The Exception:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred between lines: 11 and 13 in the jsp file:
/SessionAtempt.jsp
Generated servlet error:
C:\jakarta-tomcat-4.0.2\work\localhost\rd\SessionAtempt$jsp.java:60: Class
org.apache.jsp.MyClass not found.
MyClass sessionvars = null;
^
...
Code snippets:
Servlet: Constructing the object:
MyClass sessionvars = new MyClass (parm1, parm2, parm3, parmn);
HttpSession ses = req.getSession(true);
ses.setAttribute("Sessionvars", "sessionvars");
Servlet Sending the class:
public void GoToPage(String addy, HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
RequestDispatcher disp =
getServletContext().getRequestDispatcher(addy);
disp.forward(req, res);
}
JSP:
<jsp:useBean id="sessionvars"
class=" MyClass "
scope="session" />
Any direction would be greatly appreciated
TIA
Ernst Bekker ernst@isservices.co.za
Coding Clerk +27 +11 489 4147
IS Services ....................
____
Confidentiality Caution and Disclaimer
This message and/or any attachment thereto ("the message")
contains privileged and confidential information intended
only for the recipient named above.
If you are not the intended recipient of this message,
please erase it permanently once you have notified the
sender, per return e-mail, that you have received the
message in error.
Unless the sender is duly authorised by either the Telesure
Group, or any of its subsidiary companies or I.S Services
("the Group") to send this message and unless the content
of this message is also duly authorised by the Group, any
views expressed in this message are those of the individual
sender and the Group will not accept liability therefore,
nor for any consequential damage arising therefrom.
Any recipient of an unacceptable communication, a chain
letter or offensive material of any nature is requested
to report it to postmaster@isservices.co.za.
--
To unsubscribe: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>
Re: NEWBIE: Passing object from Servlet to JSP with session?
Posted by Lev Assinovsky <le...@peterlink.ru>.
Bean should have one constractor without papameters.
Besides if you setup new directory (the place where you made it is for
new application)
you should I think put into server.xml the same staff as for examples:
<!-- Tomcat Examples Context -->
<Context path="/examples" docBase="examples" debug="0"
reloadable="true" crossContext="true">
....
</Context>
Ernst Bekker wrote:
>
> Hi,
> I am running TomCat 4, and am attempting to forward an object to a JSP from
> a servlet.
> I have set up a new directory under .../webapps and the class files for both
> the servlet
> and the class of which I am trying to send an instance of are in .../
> webapps/newdir/WEB-INF/classes.
> The JSP file is in .../webapps/newdir.
>
> It seems that the servlet forwards the request but the JSP coughs up the
> following exception:
> The Exception:
> org.apache.jasper.JasperException: Unable to compile class for JSP
> An error occurred between lines: 11 and 13 in the jsp file:
> /SessionAtempt.jsp
> Generated servlet error:
> C:\jakarta-tomcat-4.0.2\work\localhost\rd\SessionAtempt$jsp.java:60: Class
> org.apache.jsp.MyClass not found.
> MyClass sessionvars = null;
> ^
> ...
>
> Code snippets:
> Servlet: Constructing the object:
> MyClass sessionvars = new MyClass (parm1, parm2, parm3, parmn);
> HttpSession ses = req.getSession(true);
> ses.setAttribute("Sessionvars", "sessionvars");
>
> Servlet Sending the class:
> public void GoToPage(String addy, HttpServletRequest req,
> HttpServletResponse res)
> throws ServletException, IOException
> {
> RequestDispatcher disp =
> getServletContext().getRequestDispatcher(addy);
> disp.forward(req, res);
> }
>
> JSP:
> <jsp:useBean id="sessionvars"
> class=" MyClass "
> scope="session" />
>
> Any direction would be greatly appreciated
> TIA
> Ernst Bekker ernst@isservices.co.za
> Coding Clerk +27 +11 489 4147
> IS Services ....................
>
> ____
>
> Confidentiality Caution and Disclaimer
>
> This message and/or any attachment thereto ("the message")
> contains privileged and confidential information intended
> only for the recipient named above.
> If you are not the intended recipient of this message,
> please erase it permanently once you have notified the
> sender, per return e-mail, that you have received the
> message in error.
> Unless the sender is duly authorised by either the Telesure
> Group, or any of its subsidiary companies or I.S Services
> ("the Group") to send this message and unless the content
> of this message is also duly authorised by the Group, any
> views expressed in this message are those of the individual
> sender and the Group will not accept liability therefore,
> nor for any consequential damage arising therefrom.
> Any recipient of an unacceptable communication, a chain
> letter or offensive material of any nature is requested
> to report it to postmaster@isservices.co.za.
>
> --
> To unsubscribe: <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
--
Lev Assinovsky Peterlink Web
Programmer St. Petersburg, Russia
Tel/Fax: +7 812 3275343 197022 ul.Chapigina 7а
E-mail: lev@peterlink.ru
--
To unsubscribe: <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>