You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Maxime <ma...@free.fr> on 2005/07/11 14:43:55 UTC
[OK] [FileUpload] - Need to restart each time I upload an Image
Hello,
After my system crash, I had to reinstall Tomcat, I read the HowTo Class
Loader too, and everything is working fine !
I don't know if it's because I had my FileUpload.jar , on JRE/lib/ext +
Tomcat/common/lib + Shared/lib, now it is only on Tomcat/shared/lib and all
is ok, I don't need to restart tomcat and everything is fine.
Thank you very much !
++
Maxime
----- Original Message -----
From: "Maxime" <ma...@free.fr>
To: "Jakarta Commons Users List" <co...@jakarta.apache.org>; "Dakota
Jack" <da...@gmail.com>
Sent: Sunday, July 10, 2005 11:04 PM
Subject: Re: [FileUpload] - Need to restart each time I upload an Image
> Hello,
> Sorry if I didn't give more details.
> This code that I gave is a servlet. I call it after I fill a form.
> When I mean it's doesn't works, I wanted to say that I need to restart
> Tomcat in order to see the .jpg file, if I don't do that then I can't see
> the image.
> The JSP code is simple
>
> <HTML>
> <HEAD>
> <TITLE>DBTEST</TITLE>
> </HEAD>
> <BODY BGCOLOR="#FDF5E6">
>
> <HR WIDTH="40%">
>
> <br><br>
>
> <jsp:useBean id="Article" type="monk.NewItemBean" scope="session"
> class="monk.NewItemBean"/>
> <table align="right" width="81%" border="0" height="607">
> <tr VALIGN=TOP>
> <td>
> <center><table>
> <tr VALIGN=TOP>
> <td>
>
> <b>CaƩgorie : <%=Article.getItemPath()%> <br><br>
>
> <center> <b><%=Article.getItemTitle()%></b></center><br><br>
> <center> <%=Article.getItemDesc()%></center><br><br>
> <b>Price :<%=Article.getItemPrice()%> </b>
> <b>Quantity :<%=Article.getItemQty()%></b>
> </td>
> </tr>
> </table></center>
> </td>
> </tr>
> </table>
> <b>Image : </b><img src="/training/IMG/<%=Article.getItemPath()%>">
>
> </BODY>
> </HTML>
>
> Thank you for your patience.
>
> Maxime
>
> ----- Original Message -----
> From: "Dakota Jack" <da...@gmail.com>
> To: "Maxime" <ma...@free.fr>
> Cc: "Jakarta Commons Users List" <co...@jakarta.apache.org>
> Sent: Sunday, July 10, 2005 7:09 PM
> Subject: Re: [FileUpload] - Need to restart each time I upload an Image
>
>
> Do you mean that this code is in a JSP? What do you mean "it" doesn't
> work? What doesn't work? The JSP? What is the JSP code? Why do you
> say "[it looks] like I have to restart tomcat"? You are not being
> clear. I am sure the problem is simple.
>
> On 7/10/05, Maxime <ma...@free.fr> wrote:
>> Hello about FireFox all is ok now,
>> It's just I have to put file://C:/ and it's work. But for internet
>> things,
>> I will do like that http://localhost:8080/webapps/IMG/image.jpg.
>> But the problem is I don't want to shutdown tomcat.
>> When someone upload an image throught a Form, then we can access to this
>> image by a JSP.
>> But it doesn't work, It's look like I have to restart tomcat in order to
>> take this changement (the uploaded Image).
>>
>> The code is :
>>
>> try{
>> boolean isMultipart = FileUpload.isMultipartContent(request);
>>
>> // Create a new file upload handler
>> DiskFileUpload upload = new DiskFileUpload();
>>
>> // Set upload parameters (must exploit that)
>> int yourMaxMemorySize = 512 * 1024 * 8;
>> int yourMaxRequestSize = 1024 * 1024 * 8;
>> String yourTempDirectory = "C:\\TEMPO/";
>>
>> upload.setSizeThreshold(yourMaxMemorySize);
>> upload.setSizeMax(yourMaxRequestSize);
>> upload.setRepositoryPath(yourTempDirectory);
>>
>> //Parse the request
>> List items = upload.parseRequest(request);
>>
>> // Process the uploaded items
>> Iterator iter = items.iterator();
>> while (iter.hasNext()) {
>>
>> FileItem item = (FileItem) iter.next();
>>
>> // Process a regular form field
>> if (item.isFormField()) {
>> // Have to upgrade and do a better thing
>> if (item.getFieldName().equals("Path"))
>> {
>> Article.setItemPath(item.getString());
>> }
>> if (item.getFieldName().equals("Title"))
>> {
>> Article.setItemTitle(item.getString());
>> }
>> if (item.getFieldName().equals("Desc"))
>> {
>> Article.setItemDesc(item.getString());
>> }
>> if (item.getFieldName().equals("Price"))
>> {
>>
>> //Article.setItemPrice(Integer.parseInt(item.getString()));
>> Article.setItemPrice(item.getString());
>> }
>> if (item.getFieldName().equals("Qty"))
>> {
>> Article.setItemQty(item.getString());
>>
>> }
>>
>> }
>>
>> // Process a file upload
>> else {
>>
>> String fieldName = item.getFieldName();
>> String fileName = item.getName();
>> //String contentType = item.getContentType();
>> //boolean isInMemory = item.isInMemory();
>>
>>
>> Article.setItemPath(Article.getItemPath()+"/"+fileName);
>>
>> File uploadedFile = new File("C:\\Program
>> Files/Apache Software Foundation/Tomcat
>> 5.0/webapps/work/web/IMG/"+Article.getItemPath());
>>
>> item.write(uploadedFile);
>>
>>
>>
>> }
>> }
>>
>> Thank you
>>
>> ++
>> Maxime
>>
>> ----- Original Message -----
>> From: "Dakota Jack" <da...@gmail.com>
>> To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
>> Sent: Sunday, July 10, 2005 3:39 PM
>> Subject: Re: [FileUpload] - Need to restart each time I upload an Image
>>
>>
>> There must be something wrong with your code to shut down Tomcat.
>> What is your code? Firefox has not difficulties downloading files
>> including images.
>>
>> On 7/9/05, Maxime <ma...@free.fr> wrote:
>> > Hello,
>> > I made a form where we can upload an Image on the tomcat Server.
>> > But the problem is Tomcat must be restarted in order to take this
>> > changement (the uploaded Image).
>> > Is there any way or trick to avoid that ? (or some code for automatic
>> > restart each time I upload an image).
>> > I could define the local path ( C:/..... image.jpg ) , but I don't know
>> > why it's doesn't work on FireFox browser (it does work on IE).
>> >
>> > I am using windows XP SP 2 for testing the code, Tomcat 5.0.28 and Java
>> > 1.5.0.0_4.
>> >
>> > Thank you very much !
>> >
>> > Maxime
>> >
>>
>>
>> --
>> "You can lead a horse to water but you cannot make it float on its back."
>> ~Dakota Jack~
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>>
>
>
> --
> "You can lead a horse to water but you cannot make it float on its back."
> ~Dakota Jack~
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org