You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rodrigo Ruiz <rr...@gridsystems.com> on 2003/04/29 15:43:22 UTC

Re: How do I start with a servlet?

You could map index.jsp, or even better index.html, to your servlet, and
make it forward the request to a private page (by private, I mean a file
into WEB-INF, so it is not directly accessable from the web) after
attributes initialization.

Rodrigo Ruiz



----- Original Message -----
From: "Jim Lynch" <jw...@sgi.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Monday, March 10, 2003 3:59 PM
Subject: Re: How do I start with a servlet?


> Maybe I'd better start over.  The jsp that I would like to display
> initially (index.jsp, perhaps) has a form with a number of select
> boxes.  I need to prime some of the select boxes with values derived
> from one of the other select boxes (the database name).  I use taglib
> routines to populate these select boxes and a table with a variable
> number of rows of text input form objects.   The values in the select
> boxes come from the database and there is a slightly complex hierarchy
> of dependencies.  E. g.  The primary select box selects a datbase.  From
> that database I get a set of regions that I use to set the selections
> for another drop down list.  Based on that selection I publish a
> variable row table that includes input text form objects.
>
> Now to keep all this straight, the servlet that processes the form does
> a request.setAttribute(...) for a number of variables that are needed to
> figure out what goes in each drop down list (select) and the table.
>
> The taglib routines use these attributes to generate the variable data
> on the form.
>
> Once the attributes are set everything works nicely, but what I'm really
> trying to do is initialize all these attributes, so I want to start up
> with a servlet that has a HttpRequest variable or somehow generate one
> that I can use to call a .jsp so the taglib routines populate the data
> correctly.
>
> Sure, I can go back and redo the taglib routines to have initial values,
> but I was trying to keep all the db activity in the servlet for
> simplicity.
>
> If anyone is still with me, can I do what I'm trying to?
>
> Thanks,
> Jim.
>
> Tomcat-RND wrote:
> >
> > Hi,
> >
> > Do you wish to initalize the session or ServletContext[application] on
> > startup???.
> > If you want to fire a JSP another servlet from the init() you can invoke
by
> > writing URLConnection..
> > But I am not clear about initializing the Session info, on startup
> >
> > Do let me know if any thing found on that...
> >
> > Regards,
> > Pratt.
> >
> > ----- Original Message -----
> > From: "Jim Lynch" <jw...@sgi.com>
> > To: "Tomcat Users List" <to...@jakarta.apache.org>
> > Sent: Monday, March 10, 2003 3:55 PM
> > Subject: Re: How do I start with a servlet?
> >
> > > OK, I think I see the problem.  It did call the servlet but only the
> > > init() method.  Makes sense.  Since there is no request passed, I
can't
> > > do anything.
> > >
> > > Let me restate the question.  I'd like to start execution with a
servlet
> > > that can fire off a jsp after initializing stuff in the the session
and
> > > hopefully seting variables somewhere that the taglib routines can use.
> > > I'm starting to think there is no way to do that.  You have to begin
> > > with a document so there is a request to pass to the servelet.
> > >
> > > Thanks,
> > > Jim.
> > >
> > > "Warden, Matt" wrote:
> > > >
> > > > On Mar 9, Manolis Mavrikis had something to say about Re: How do I
> > start...
> > > >
> > > > >Jim,
> > > > >
> > > > >   Create a SetupServlet in your servlets package and use something
> > similar as
> > > > >the below part of my web.xml
> > > > >
> > > > >   you can even pass some parameters with the param-value
> > > > >
> > > > >   and if I remebmer right you put the load-on-startup tag and it
> > should start
> > > > >it on startup and initiliase whatever you want.
> > > > >
> > > > ><servlet-name>setup</servlet-name>
> > > > >      <servlet-class>wallis.servlets.SetupServlet</servlet-class>
> > > > >      <init-param>
> > > > >       <param-name>props</param-name>
> > > > >
> > <param-value>/tomcat/webapps/wallis/WEB-INF/MDC.properties</param-value>
> > > > >      </init-param>
> > > > >     <load-on-startup/>
> > > > >    </servlet>
> > > > >
> > > > > hope this helps
> > > >
> > > > But he's looking to initialize variables in each user's session.
> > > >
> > > > I've done nothing with them (not even researched them), btu from the
> > talk
> > > > on this list, it looks like either a Valve or Filter is what you
want:
> > > >
> > > > Theres's probably some info here:
> > > > http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config
> > > >
> > > > Good luck,
> > > >
> > > > --
> > > > mattwarden
> > > > mattwarden.com
> > > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org