Quoting sumit deogharia ([EMAIL PROTECTED]):

> My team is currently developing a 3 tier web-based application using
> servlets in the middle tier. Now here is the problem..... I am having some
> variables in the servlet whose values I would like to access from the
> embedded scripts of the web page thrown to me by the servlet..... but this
> is not happening. To cut the long story short, no "runat server" facility
> that is present in ASP.
> Can you all help me here i.e to access servlet variables from the embedded
> scripts of the web page .


You could use a template engine such as WebMacro. Suppose your servlet
had a Search object in it with method like Search.getResults() that
returns an array of Link objects, which have methods like Link.getAnchor()
and Link.getURL().

In WebMacro you could do a context.put("search", new Search(...)) and
then write this in your HTML template:

    <html>blah blah blah
    <ul>
      #foreach $link in $search.Results {
        <li><a href="$link.URL">$link.Anchor</a>
      }
    </ul>
    blah blah blah
    </html>

But I'm not sure I fully understand your question. I'm assuming that
by three tier architecture you mean that the browser is the first
tier and that servlets sit on the front of your webserver. In that
case, WebMacro was designed for exactly this purpose. You can
download and use it for free here:

     http://webmacro.org

If that's now what you're trying to do, and you have something
different running on the webserver, you could use something like
RMI to access your servlet layer but it's not going to follow
naturally from the servlet API.

Justin

--
[EMAIL PROTECTED]
AltaVista Company

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to