Hi,

I have a file upload Servlet that insert image into DB and I would see a
link to these images in a JSP, or at least a list.
The insert work but the list does not, because I do not know how to send
these parameters from a Servlet to a JSP.
Into HTML form I enter only the picture and not even his name.
Here is an extract from the Servlet:
***********************************************************************
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List /* FileItem */ items = upload.parseRequest(request);

Iterator iter = items.iterator();
   while (iter.hasNext()) {
      FileItem item = (FileItem) iter.next();
      name = item.getName();
      img  = item.getInputStream();
      size = item.getSize();
   }

Image image = new Image(name, img, size);  // Creo un oggetto Image che รจ un
JavaBean
ImageCRUD ic = new ImageCRUD();             // Classe CRUD per le operazioni
nel DB
ic.addImage( image );                                 // Inserisco
l'immagine nel DB
ResultSet rs = ic.listImage();                      // Seleziono le immagini

RequestDispatcher dispatcher;
dispatcher = getServletContext().getRequestDispatcher("/ShowImage.jsp");
dispatcher.forward(request,response);
***********************************************************************

Now in JSP would like a list of images (in another words the variable name
of the Servlet). Something like:
***********************************************************************
<% String name = request.getParameter ( "name");%>

/ / On a cycle for the recurrence of cells of the table
<tr>
     <td Align="right"> Name: </ td> <td> <=% name%> </ td>
</ Tr>
***********************************************************************

Of course, this code does not work and is probably nonsense, but I put to
the idea.
I am sorry for this approximation.

Thank you for your attention,
Matteo

Reply via email to