tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anne Dirkse" <aldir...@uswest.net>
Subject Re: file upload servlet
Date Sun, 22 Apr 2001 19:40:54 GMT
Christoph --
You do need the trailing = after <%
Here's why:
What you are trying to send from your HTML form is something like this:

<form enctype="multipart/form-data" action="/servlets/servlet/Upload"
method="post">
<input type="file" name="FileData" value="" size="52" maxlength="255">
<input type="submit" value="Abschicken">
</form>

The <%= %> is a jsp Expression, which means that the value of whatever
is in it will be converted to a String and then printed out. Since this
is done before the HTML is processed, what you get is something like in
the above example.
As you have it below, with <% %>, you are not ever actually including
the value of your encoded URL into your form.
It's just a scriptlet, which will actually encode your URL, but to no
avail, since it has no explicit String conversion or printout
capabilities and thus won't be a part of your form.

all the <%= response.encodeURL("/path/to/Servlet") %> is doing is
rewriting your URL to include session data if cookies are not enabled.
For a first shot at it, you might want to consider just building a set
of tags like I included above and making sure that works (make sure you
have cookies enabled, though!) After you have that working, it might be
a lot easier to get your session encoding working, conceptually. 

What the leftover method="post"> signals to me is that somewhere you are
closing the form tag before this part of it, i.e., that the browser
encounters a > before it encounters method="post"> and thus assumes that
the form tag has been completed and that method="post"> is regular text
to be printed to the browser window.

Hope that helps,
Anne

Christoph Kukulies wrote:
> 
> On Sun, Apr 22, 2001 at 11:05:44AM -0700, Anne Dirkse wrote:
> > My guess is that you have an extra > somewhere (or that you missed the <
> > at action=<%=)
> 
> The trailing = looks like being added by the mailer.
> 
> It seems to me that I'm missing something more essential. I'm running
> tomcat 3.2 beta. The (jsp) examples all seem to work.
> 
> Even written like this:
> <html>
> <form enctype="multipart/form-data" action=<%
>  response.encodeUrl("/servlets/servlet/Upload")
> %>
> method="post">
> <input type="file" name="FileData" value="" size="52" maxlength="255">
> <input type="submit" value="Abschicken">
> </form>
> </html>
> 
> doesn't change the picture.
> 
> >
> > Anne
> >
> > Christoph Kukulies wrote:
> > >
> > > On Fri, Apr 20, 2001 at 06:58:26PM +0200, Ralph Einfeldt wrote:
> > > > For a pure HTML solution you need two things:
> > > >
> > > > a form with at least one file input tag:
> > > >
> > > > <form enctype="multipart/form-data" action=<%=
> > > > response.encodeUrl("'path-to-your-servlet'") %> method="post">
> > > > <input type="file" name="FileData" value="" size="52" maxlength="255">
> > > > </form>
> > >
> > > This is looking very elegant to me. I tried it but I'm getting
> > >
> > > method="post">
> > >
> > > at the beginning of the page when it appears in the browser.
> > >
> > > Is there a typo (or some mail agent added something, like a '=' sign?)
> > > or am I missing something more severe?
> > >
> > > --
> > > Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de
> 
> --
> Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de

Mime
View raw message