You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lauri <db...@hotmail.com> on 2023/06/01 08:52:38 UTC

Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

I don't ask to fix the code. I wish to understand what is wrong how it can be possibly solved keeping the format of a JSP page.
You mention a servlet part, but I do not use a servlet.
All the code is contained in the JSP page.
________________________________
From: Torsten Krah <kr...@gmail.com>
Sent: Wednesday, May 31, 2023 11:53 AM
To: users@tomcat.apache.org <us...@tomcat.apache.org>
Subject: Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Am Mittwoch, dem 31.05.2023 um 09:42 +0000 schrieb Lauri:
> But my initial question remains, what should have to modify on my
> posted JSP page ?

We already posted you with the docs where you can read about the
necessary changes you need to make to your page, it is all written
there (just call getParts() or getPart(..) on the servlet request
object).

You can ask about specific failures again if you have errors etc. but
at least I don't fix your code to make it work - you can do that
yourself and ask again if something isn't working like expected, after
reading the docs we pointed you to and adapting your page.

That's my 2 cents about it.

kind regards

Torsten
--

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


AW: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Posted by "Thomas Hoffmann (Speed4Trade GmbH)" <Th...@speed4trade.com.INVALID>.
Hello,

> -----Ursprüngliche Nachricht-----
> Von: Torsten Krah <kr...@gmail.com>
> Gesendet: Donnerstag, 1. Juni 2023 11:18
> An: users@tomcat.apache.org
> Betreff: Re: Re-Cannot upload an image file from a deployed JSP page in
> Tomcat 10
> 
> Am Donnerstag, dem 01.06.2023 um 08:52 +0000 schrieb Lauri:
> > > You mention a servlet part, but I do not use a servlet.
> > > All the code is contained in the JSP page.
> 
> You need to divide that code in a JSP and in your upload servlet as you need
> to provide the @MultipartConfig on that servlet which handles your upload.
> Without that you will get:
> 
> Unable to process parts as no multi-part configuration has been provided
> 
> as an exception when accessing the request.getParts() API.
> 
> The whole thing is all written there btw:
> 
> https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html
> 
> I don't know - maybe Mark does - if you can annotate a JSP page, had never
> seen it or read about that so my best guess is, you can't do that and you need
> to use a servlet + jsp unless you want to overwrite the JspServlet from
> Tomcat with a custom one which does have that annotation and handles the
> Jsp stuff.
> 
> kind regards
> 
> Torsten
> 

In general it is good practice to separate logic and layout.
JSP are usually for providing the view / layout.
Logic / java code should be used in servlets and other java classes (e.g. models).

So it is recommended anyway to move java code from JSP to java classes.
See https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller 

Greetings,
Thomas
 


Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Lauri,

On 6/10/23 03:18, Lauri wrote:
> Hi,
> Thanks for all the tips.
> It is solved.
> I managed to create such a working page in Tomcat 9 (without any specific configuration).
> I just deployed that same page in Tomcat 10(also without any specific configuration), and it works.
> For the rest, I will wait for Tomcat 11. I guess it will be a more stable version.

Tomcat 10 is very stable, and will likely behave the same as Tomcat 11 
will. The problem is that you are fighting against the API-switchover 
from Java EE to Jakarta EE which is confusing to everybody. The good 
news is that Tomcat supports that switchover in a very elegant fashion.

-chris

> From: Christopher Schultz <ch...@christopherschultz.net>
> Sent: Friday, June 2, 2023 4:45 PM
> To: users@tomcat.apache.org <us...@tomcat.apache.org>
> Subject: Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10
> 
> Lauri,
> 
> On 6/2/23 02:58, Lauri wrote:
>> @Thomas:
>>
>> I have made a test using the request.getParts() API, as mentioned here:
>> https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html
>>
>> The test upload application has been modified as:
>>
>> -- web.xml
>> ---
>> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
>>            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>            xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>>                                http://xmlns.jcp.org/xml/ns/javaee/web-app_5_0.xsd"
> 
> 
> If you want to use Tomcat 10, these are the wrong XML schema references.
> You want the Jakarta ones.
> 
>> <%@ page import="java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*" %>
> 
> If you want to use Tomcat 10, these are the wrong packages. You want the
> Jakarta ones.
> 
> -chris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 

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


Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Posted by Lauri <db...@hotmail.com>.
Hi,
Thanks for all the tips.
It is solved.
I managed to create such a working page in Tomcat 9 (without any specific configuration).
I just deployed that same page in Tomcat 10(also without any specific configuration), and it works.
For the rest, I will wait for Tomcat 11. I guess it will be a more stable version.
Kind Regards,
Lauri

________________________________
From: Christopher Schultz <ch...@christopherschultz.net>
Sent: Friday, June 2, 2023 4:45 PM
To: users@tomcat.apache.org <us...@tomcat.apache.org>
Subject: Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Lauri,

On 6/2/23 02:58, Lauri wrote:
> @Thomas:
>
> I have made a test using the request.getParts() API, as mentioned here:
> https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html
>
> The test upload application has been modified as:
>
> -- web.xml
> ---
> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
>           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>                               http://xmlns.jcp.org/xml/ns/javaee/web-app_5_0.xsd"


If you want to use Tomcat 10, these are the wrong XML schema references.
You want the Jakarta ones.

> <%@ page import="java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*" %>

If you want to use Tomcat 10, these are the wrong packages. You want the
Jakarta ones.

-chris

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


Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Lauri,

On 6/2/23 02:58, Lauri wrote:
> @Thomas:
> 
> I have made a test using the request.getParts() API, as mentioned here:
> https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html
> 
> The test upload application has been modified as:
> 
> -- web.xml
> ---
> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
>           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>                               http://xmlns.jcp.org/xml/ns/javaee/web-app_5_0.xsd"


If you want to use Tomcat 10, these are the wrong XML schema references. 
You want the Jakarta ones.

> <%@ page import="java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*" %>

If you want to use Tomcat 10, these are the wrong packages. You want the 
Jakarta ones.

-chris

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


AW: AW: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Posted by "Thomas Hoffmann (Speed4Trade GmbH)" <Th...@speed4trade.com.INVALID>.
Hello Mark,

> -----Ursprüngliche Nachricht-----
> Von: Mark Thomas <ma...@apache.org>
> Gesendet: Freitag, 2. Juni 2023 14:18
> An: users@tomcat.apache.org
> Betreff: Re: AW: Re-Cannot upload an image file from a deployed JSP page in
> Tomcat 10
> 
> On 02/06/2023 08:20, Thomas Hoffmann (Speed4Trade GmbH) wrote:
> > Hello Lauri,
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Lauri <db...@hotmail.com>
> >> Gesendet: Freitag, 2. Juni 2023 08:58
> >> An: Tomcat Users List <us...@tomcat.apache.org>
> >> Betreff: Re-Cannot upload an image file from a deployed JSP page in
> >> Tomcat
> >> 10
> >>
> >> @Thomas:
> >>
> >> I have made a test using the request.getParts() API, as mentioned here:
> >> https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html
> >>
> >> The test upload application has been modified as:
> >>
> >> -- web.xml
> >> ---
> >> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
> >>           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >>           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
> >>                               http://xmlns.jcp.org/xml/ns/javaee/web-app_5_0.xsd"
> >>           version="5.0">
> >> </web-app>
> >> ---
> >>
> >> -- index.html
> >> ---
> >> <!DOCTYPE html>
> >> <html>
> >> <head>
> >> <meta charset="UTF-8">
> >> <title>Upload Text File</title>
> >> </head>
> >> <body>
> >>      <h1>Upload File</h1>
> >>      <form action="upload.jsp" method="post" enctype="multipart/form-
> >> data">
> >>          <input type="file" name="file" />
> >>          <input type="submit" value="Upload" />
> >>      </form>
> >> </body>
> >> </html>
> >> ---
> >>
> >> -- upload.jsp
> >> ---
> >> <%@ page import="java.io.*, java.util.*, javax.servlet.*,
> javax.servlet.http.*"
> >> %> <%
> >>    Part part = request.getPart("file");
> >>    if (part != null) {
> >>      InputStream stream = part.getInputStream();
> >>      File file = new File("/tmp/" + part.getSubmittedFileName());
> >>      FileOutputStream outputStream = new FileOutputStream(file);
> >>      byte[] buffer = new byte[4096];
> >>      int bytesRead = -1;
> >>      while ((bytesRead = stream.read(buffer)) != -1) {
> >>        outputStream.write(buffer, 0, bytesRead);
> >>      }
> >>      outputStream.close();
> >>      stream.close();
> >>    } else {
> >>      out.println("No file uploaded.");
> >>    }
> >> %>
> >> ---
> >>
> >> The @MultipartConfig is defined in the HTML file.
> >
> > The @MultipartConfig must be used in the servlet.
> > Here are examples:
> > https://stackoverflow.com/questions/19145489/multipartconfig-override-
> > in-web-xml Multipart-Upload with the mentioned methods can't be done
> > with JSP-Files solely as far as I can see.
> 
> That is not correct. You CAN use multi-part upload with JSP files.
> Rather than using the annotation, you have to define the upload in web.xml.
> See an earlier post from me in this thread for some links to some examples.

Thanks for the correction!
Now I understand the example in your link.

The trick is:
           <multipart-config>
               <location>/temp</location>
           ....

> Mark
> 
> ---------------------------------------------------------------------


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


Re: AW: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Posted by Mark Thomas <ma...@apache.org>.
On 02/06/2023 08:20, Thomas Hoffmann (Speed4Trade GmbH) wrote:
> Hello Lauri,
> 
>> -----Ursprüngliche Nachricht-----
>> Von: Lauri <db...@hotmail.com>
>> Gesendet: Freitag, 2. Juni 2023 08:58
>> An: Tomcat Users List <us...@tomcat.apache.org>
>> Betreff: Re-Cannot upload an image file from a deployed JSP page in Tomcat
>> 10
>>
>> @Thomas:
>>
>> I have made a test using the request.getParts() API, as mentioned here:
>> https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html
>>
>> The test upload application has been modified as:
>>
>> -- web.xml
>> ---
>> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
>>           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>>                               http://xmlns.jcp.org/xml/ns/javaee/web-app_5_0.xsd"
>>           version="5.0">
>> </web-app>
>> ---
>>
>> -- index.html
>> ---
>> <!DOCTYPE html>
>> <html>
>> <head>
>> <meta charset="UTF-8">
>> <title>Upload Text File</title>
>> </head>
>> <body>
>>      <h1>Upload File</h1>
>>      <form action="upload.jsp" method="post" enctype="multipart/form-
>> data">
>>          <input type="file" name="file" />
>>          <input type="submit" value="Upload" />
>>      </form>
>> </body>
>> </html>
>> ---
>>
>> -- upload.jsp
>> ---
>> <%@ page import="java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*"
>> %> <%
>>    Part part = request.getPart("file");
>>    if (part != null) {
>>      InputStream stream = part.getInputStream();
>>      File file = new File("/tmp/" + part.getSubmittedFileName());
>>      FileOutputStream outputStream = new FileOutputStream(file);
>>      byte[] buffer = new byte[4096];
>>      int bytesRead = -1;
>>      while ((bytesRead = stream.read(buffer)) != -1) {
>>        outputStream.write(buffer, 0, bytesRead);
>>      }
>>      outputStream.close();
>>      stream.close();
>>    } else {
>>      out.println("No file uploaded.");
>>    }
>> %>
>> ---
>>
>> The @MultipartConfig is defined in the HTML file.
> 
> The @MultipartConfig must be used in the servlet.
> Here are examples: https://stackoverflow.com/questions/19145489/multipartconfig-override-in-web-xml
> Multipart-Upload with the mentioned methods can't be done with JSP-Files solely as far as I can see.

That is not correct. You CAN use multi-part upload with JSP files. 
Rather than using the annotation, you have to define the upload in 
web.xml. See an earlier post from me in this thread for some links to 
some examples.

Mark

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


AW: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Posted by "Thomas Hoffmann (Speed4Trade GmbH)" <Th...@speed4trade.com.INVALID>.
Hello Lauri,

> -----Ursprüngliche Nachricht-----
> Von: Lauri <db...@hotmail.com>
> Gesendet: Freitag, 2. Juni 2023 08:58
> An: Tomcat Users List <us...@tomcat.apache.org>
> Betreff: Re-Cannot upload an image file from a deployed JSP page in Tomcat
> 10
> 
> @Thomas:
> 
> I have made a test using the request.getParts() API, as mentioned here:
> https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html
> 
> The test upload application has been modified as:
> 
> -- web.xml
> ---
> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
>                              http://xmlns.jcp.org/xml/ns/javaee/web-app_5_0.xsd"
>          version="5.0">
> </web-app>
> ---
> 
> -- index.html
> ---
> <!DOCTYPE html>
> <html>
> <head>
> <meta charset="UTF-8">
> <title>Upload Text File</title>
> </head>
> <body>
>     <h1>Upload File</h1>
>     <form action="upload.jsp" method="post" enctype="multipart/form-
> data">
>         <input type="file" name="file" />
>         <input type="submit" value="Upload" />
>     </form>
> </body>
> </html>
> ---
> 
> -- upload.jsp
> ---
> <%@ page import="java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*"
> %> <%
>   Part part = request.getPart("file");
>   if (part != null) {
>     InputStream stream = part.getInputStream();
>     File file = new File("/tmp/" + part.getSubmittedFileName());
>     FileOutputStream outputStream = new FileOutputStream(file);
>     byte[] buffer = new byte[4096];
>     int bytesRead = -1;
>     while ((bytesRead = stream.read(buffer)) != -1) {
>       outputStream.write(buffer, 0, bytesRead);
>     }
>     outputStream.close();
>     stream.close();
>   } else {
>     out.println("No file uploaded.");
>   }
> %>
> ---
> 
> The @MultipartConfig is defined in the HTML file.

The @MultipartConfig must be used in the servlet.
Here are examples: https://stackoverflow.com/questions/19145489/multipartconfig-override-in-web-xml 
Multipart-Upload with the mentioned methods can't be done with JSP-Files solely as far as I can see.
Only Servlets can be annotated or declared with MultipartConfig

I suggest to read some pages about servlets and also take a look at try-with-ressource.
Your topic is more about servlet and jsp programming and less about tomcat.



> When deployed in Tomcat 10, I still get these errors:
> 
> ---
> org.apache.jasper.JasperException: An exception occurred processing
> [/upload.jsp] at line [3]
> 
> 1: <%@ page import="java.io.*, java.util.*, javax.servlet.*,
> javax.servlet.http.*" %>
> 2: <%
> 3:   Part part = request.getPart("file");
> 4:   if (part != null) {
> 5:     InputStream stream = part.getInputStream();
> 6:     File file = new File("/tmp/" + part.getSubmittedFileName());
> ---
> 
> @Mark:
> 
> Refering to:
> https://stackoverflow.com/questions/37965890/add-annotation-to-jsp
> 
> I do not upload a (image) file to the database, but on the server (/tmp).
> 
> Kind Regards
> 
> ________________________________
> From: Mark Thomas <ma...@apache.org>
> Sent: Thursday, June 1, 2023 11:29 AM
> To: users@tomcat.apache.org <us...@tomcat.apache.org>
> Subject: Re: Re-Cannot upload an image file from a deployed JSP page in
> Tomcat 10
> 
> On 01/06/2023 10:18, Torsten Krah wrote:
> > Am Donnerstag, dem 01.06.2023 um 08:52 +0000 schrieb Lauri:
> >>> You mention a servlet part, but I do not use a servlet.
> >>> All the code is contained in the JSP page.
> >
> > You need to divide that code in a JSP and in your upload servlet as
> > you need to provide the @MultipartConfig on that servlet which handles
> > your upload.
> > Without that you will get:
> >
> > Unable to process parts as no multi-part configuration has been
> > provided
> >
> > as an exception when accessing the request.getParts() API.
> >
> > The whole thing is all written there btw:
> >
> > https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html
> >
> > I don't know - maybe Mark does - if you can annotate a JSP page, had
> > never seen it or read about that so my best guess is, you can't do
> > that and you need to use a servlet + jsp unless you want to overwrite
> > the JspServlet from Tomcat with a custom one which does have that
> > annotation and handles the Jsp stuff.
> 
> You can do this via web.xml. See the following SO question for an example
> specific to this question:
> 
> https://stackoverflow.com/questions/37965890/add-annotation-to-jsp
> 
> For some more general examples:
> 
> https://github.com/apache/tomcat/blob/main/test/webapp/WEB-
> INF/web.xml
> 
> Search for "<jsp-file>"
> 
> Mark
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


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


Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Posted by Lauri <db...@hotmail.com>.
@Thomas:

I have made a test using the request.getParts() API, as mentioned here:
https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html

The test upload application has been modified as:

-- web.xml
---
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                             http://xmlns.jcp.org/xml/ns/javaee/web-app_5_0.xsd"
         version="5.0">
</web-app>
---

-- index.html
---
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Upload Text File</title>
</head>
<body>
    <h1>Upload File</h1>
    <form action="upload.jsp" method="post" enctype="multipart/form-data">
        <input type="file" name="file" />
        <input type="submit" value="Upload" />
    </form>
</body>
</html>
---

-- upload.jsp
---
<%@ page import="java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*" %>
<%
  Part part = request.getPart("file");
  if (part != null) {
    InputStream stream = part.getInputStream();
    File file = new File("/tmp/" + part.getSubmittedFileName());
    FileOutputStream outputStream = new FileOutputStream(file);
    byte[] buffer = new byte[4096];
    int bytesRead = -1;
    while ((bytesRead = stream.read(buffer)) != -1) {
      outputStream.write(buffer, 0, bytesRead);
    }
    outputStream.close();
    stream.close();
  } else {
    out.println("No file uploaded.");
  }
%>
---

The @MultipartConfig is defined in the HTML file.

When deployed in Tomcat 10, I still get these errors:

---
org.apache.jasper.JasperException: An exception occurred processing [/upload.jsp] at line [3]

1: <%@ page import="java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*" %>
2: <%
3:   Part part = request.getPart("file");
4:   if (part != null) {
5:     InputStream stream = part.getInputStream();
6:     File file = new File("/tmp/" + part.getSubmittedFileName());
---

@Mark:

Refering to:
https://stackoverflow.com/questions/37965890/add-annotation-to-jsp

I do not upload a (image) file to the database, but on the server (/tmp).

Kind Regards

________________________________
From: Mark Thomas <ma...@apache.org>
Sent: Thursday, June 1, 2023 11:29 AM
To: users@tomcat.apache.org <us...@tomcat.apache.org>
Subject: Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

On 01/06/2023 10:18, Torsten Krah wrote:
> Am Donnerstag, dem 01.06.2023 um 08:52 +0000 schrieb Lauri:
>>> You mention a servlet part, but I do not use a servlet.
>>> All the code is contained in the JSP page.
>
> You need to divide that code in a JSP and in your upload servlet as you
> need to provide the @MultipartConfig on that servlet which handles your
> upload.
> Without that you will get:
>
> Unable to process parts as no multi-part configuration has been provided
>
> as an exception when accessing the request.getParts() API.
>
> The whole thing is all written there btw:
>
> https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html
>
> I don't know - maybe Mark does - if you can annotate a JSP page, had
> never seen it or read about that so my best guess is, you can't do that
> and you need to use a servlet + jsp unless you want to overwrite the
> JspServlet from Tomcat with a custom one which does have that
> annotation and handles the Jsp stuff.

You can do this via web.xml. See the following SO question for an
example specific to this question:

https://stackoverflow.com/questions/37965890/add-annotation-to-jsp

For some more general examples:

https://github.com/apache/tomcat/blob/main/test/webapp/WEB-INF/web.xml

Search for "<jsp-file>"

Mark

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


Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Posted by Mark Thomas <ma...@apache.org>.
On 01/06/2023 10:18, Torsten Krah wrote:
> Am Donnerstag, dem 01.06.2023 um 08:52 +0000 schrieb Lauri:
>>> You mention a servlet part, but I do not use a servlet.
>>> All the code is contained in the JSP page.
> 
> You need to divide that code in a JSP and in your upload servlet as you
> need to provide the @MultipartConfig on that servlet which handles your
> upload.
> Without that you will get:
> 
> Unable to process parts as no multi-part configuration has been provided
> 
> as an exception when accessing the request.getParts() API.
> 
> The whole thing is all written there btw:
> 
> https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html
> 
> I don't know - maybe Mark does - if you can annotate a JSP page, had
> never seen it or read about that so my best guess is, you can't do that
> and you need to use a servlet + jsp unless you want to overwrite the
> JspServlet from Tomcat with a custom one which does have that
> annotation and handles the Jsp stuff.

You can do this via web.xml. See the following SO question for an 
example specific to this question:

https://stackoverflow.com/questions/37965890/add-annotation-to-jsp

For some more general examples:

https://github.com/apache/tomcat/blob/main/test/webapp/WEB-INF/web.xml

Search for "<jsp-file>"

Mark

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


Re: Re-Cannot upload an image file from a deployed JSP page in Tomcat 10

Posted by Torsten Krah <kr...@gmail.com>.
Am Donnerstag, dem 01.06.2023 um 08:52 +0000 schrieb Lauri:
> > You mention a servlet part, but I do not use a servlet.
> > All the code is contained in the JSP page.

You need to divide that code in a JSP and in your upload servlet as you
need to provide the @MultipartConfig on that servlet which handles your
upload.
Without that you will get:

Unable to process parts as no multi-part configuration has been provided

as an exception when accessing the request.getParts() API.

The whole thing is all written there btw:

https://docs.oracle.com/javaee/6/tutorial/doc/glrbb.html

I don't know - maybe Mark does - if you can annotate a JSP page, had
never seen it or read about that so my best guess is, you can't do that
and you need to use a servlet + jsp unless you want to overwrite the
JspServlet from Tomcat with a custom one which does have that
annotation and handles the Jsp stuff.

kind regards

Torsten

-- 


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