Rob Fahey wrote:
>
> Hi All,
>
> I'm just starting out with JSP programming, coming from a background in
> webdev.... I've hit a snag in including a beanlet on a page which I was
> hoping someone could help me with, as I'm sure it's pretty basic!
>
> I am including the bean on the page as follows:
>
> <jsp:useBean id="registerbean" scope="session" class="AMCreg.register"
> />
>
> I want to process all the data sent from a form on the previous page
> (thats quite a lot of data) in this beanlet. However, because it's a
> general purpose processing class, I don't know exactly what the fields
> in the POST/GET data will be... Hence, I have written a procedure into
> the beanlet which should process the request object, extract the data
> from it and store it in the Session object for later processing.
>
> public void processRequest(HttpServletRequest request) {
> ... do stuff ...
> }
>
> Now, to my mind, based on my knowledge of general servlets, this process
> should be called as soon as I instantiate the beanlet on the page.
> However, as far as I can see, it isn't called at all... (I have debug
> lines in there which don't produce any output, which tells me that the
> method is never accessed).
>
> My question is, what am I doing wrong...? And am I approaching this in
> the right way in the first place? I have assumed all along that JSP
> beanlets have full access to the HttpServletRequest object... am I
> correct in this assumption?
In JSP 0.92, a method named processRequest() was always called on a bean
when it was created, but this is no longer the case in JSP 1.0 and 1.1.
If you want something to happen only when the bean is created, you can put
it in the body of the useBean element:
<jsp:useBean id="registerbean" scope="session" class="AMCreg.register">
<% registerbean.processRequest(request); %>
</jsp:useBean>
In JSP 1.1, you may want to change the bean into a custom action instead,
see the Tag Extension Framework section of the JSP 1.1 spec
<http://java.sun.com/products/jsp/>
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html