You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Wolfram Laube <Wo...@activeweb.at> on 2002/02/01 12:15:14 UTC

Problem porting webapp from Orion / Resin to Tomcat 4.0.1

Hi,

This is my first posting on this list, so I hope I meet
the communication standards (if not, just beat me up (verbally)).

I had to develop an application that generates dynamic
XML out of DB content via JSPs; the JSPs' output
is passed through a Servlet 2.3 filter and transformed into
whatever format the requesting device is able to display.
Customer chose Resin 2.04, and all worked fine
(Orion 1.5.3's OK, too.)

New customer has objected to use any of these JSP-Engines
but wants Tomcat as deployment target, so I tried porting
it to Tomcat, but am experiencing the following massive
trouble:
Trying to tweak the content type of the response
from text/xml to e. g. text/html simply has no effect;
the transformed output comes as text/xml to the browser,
which will
a) ask what to do with page of type text/xml, if not XML-enabled
b) get stuck in a parse exception, if XML-enabled
(since the transformed content isn't well formed XML,
but e.g. HTML)

The relevant portions of the filter code are the following:

    public void doFilter(ServletRequest request, ...)
        throws IOException, ServletException
    {
        OutputStream out = response.getOutputStream();
        GenericResponseWrapper wrapper =
            new GenericResponseWrapper((HttpServletResponse)response);
        chain.doFilter(request,wrapper);

        String s;
        if((s = wrapper.getContentType()) != null)
        {
            if(s.indexOf("text/xml") >= 0)
            {
                response.setContentType("text/html"); // THIS DOESN'T
WORK

                String media = null, title = null, charset = null;
                InputStream xmlStream = null;
                Source xmlSource = null;
                Source xslSource = null;
                try
                {
                    //... transform XML and write into output...


response.setContentLength(charArrayWriter.toString().length());
                    out.write(charArrayWriter.toString().getBytes());

                    out.flush();

                    //... close XML Stream and the like...
                }
                catch (TransformerException e)
                {
                    out.write(e.getMessage().getBytes());
                    out.flush();
                }
            }
            else
            {
                response.setContentType(s);
                out.write(wrapper.getData());
                out.flush();
            }
        }
        out.close();
        response.flushBuffer();
    }


Has anyone experienced the like? What am I doing wrong?

Thanks,
Wolfram



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Where's the MemeryRealm user-info stored?

Posted by Michel <ma...@freeler.nl>.
Howdy y'all

I've enabled a Tomcat 4.0.1 memory realm for protecting parts of my website
with a username/password.

When I try to access the protected JSPs I get this ugly Windows/IE
login-window.

What I would like to do is to create a HTML/JSP form where the user can
enter his login credentials beforehand, so that the standard Windows/IE
login-window isn't shown anymore when he's accessing the protected area but
instead the credentials already entered should be used. Based on this info,
I would also like to hade/show some parts of my website.

Any idea how to store the credentials so that the Memory Realm can make use
of it?

gr. Michel


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>