Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3968 connectés 

 


Dernière réponse
Sujet : [servlet/JSP] afficher des images lues par ma servlet (ou ma JSP)
El_gringo S'il vous plait, regardez si vous voyez un truc qui cloche, moi j'y arrive pas ! (IE6).
En fait, j'essaye de faire afficher au browser, des images lues par ma servlet.
 

Code :
  1. // Method of a "Page" class
  2. public void write (OutputStream out) {
  3.   // Reading of the tiff file (this.tempFile is a valid File)
  4.   PlanarImage image    = JAI.create("fileload", this.tempFile.getCanonicalPath ());
  5.   /*   // Test : the writed file is a valid tiff file --> the reading is OK !
  6.    *   File outFile = new File ("c:\\temp\\JLdsWeb\\Test.tif" );
  7.    *   RenderedOp op = JAI.create("filestore", image, outFile.getCanonicalPath (), "tiff" );
  8.    */
  9.    // Writing of the tiff file in the received OutputStream
  10.    JAI.create("encode", image, out, this.FORMAT_NAME, null);
  11. }
  12. // my 1st JSP :page.jsp (to call the 2nd JSP witch have an other content type)
  13. <%@page
  14. contentType="text/html"
  15. language="java"
  16. errorPage="errorpage.jsp"
  17. import="com.damaris.ldsweb.*,com.damaris.data.*,com.damaris.page.*,java.util.*"
  18. %>
  19. <html>
  20. <head></head>
  21. <body>
  22. <IMG src=<%=request.getContextPath()%>image.jsp>
  23. </body>
  24. </html>
  25. // my 2nd JSP
  26. <%@page
  27. language="java"
  28. errorPage="errorpage.jsp"
  29. import="com.damaris.ldsweb.*,com.damaris.data.*,com.damaris.page.*,java.util.*"
  30. %>
  31. <html>
  32. <head>
  33. <%
  34.     // pageToPrint is an instance of the class "Page" (getContentType ( ) give the String "image/tiff" )
  35.     response.setContentType(pageToPrint.getContentType ( ));
  36. %>
  37. </head>
  38. <body>
  39. <%
  40.     ServletOutputStream bOut = response.getOutputStream();
  41.     pageToPrint.write (bOut);
  42. %>
  43. </body>
  44. </html>


Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
El_gringo S'il vous plait, regardez si vous voyez un truc qui cloche, moi j'y arrive pas ! (IE6).
En fait, j'essaye de faire afficher au browser, des images lues par ma servlet.
 

Code :
  1. // Method of a "Page" class
  2. public void write (OutputStream out) {
  3.   // Reading of the tiff file (this.tempFile is a valid File)
  4.   PlanarImage image    = JAI.create("fileload", this.tempFile.getCanonicalPath ());
  5.   /*   // Test : the writed file is a valid tiff file --> the reading is OK !
  6.    *   File outFile = new File ("c:\\temp\\JLdsWeb\\Test.tif" );
  7.    *   RenderedOp op = JAI.create("filestore", image, outFile.getCanonicalPath (), "tiff" );
  8.    */
  9.    // Writing of the tiff file in the received OutputStream
  10.    JAI.create("encode", image, out, this.FORMAT_NAME, null);
  11. }
  12. // my 1st JSP :page.jsp (to call the 2nd JSP witch have an other content type)
  13. <%@page
  14. contentType="text/html"
  15. language="java"
  16. errorPage="errorpage.jsp"
  17. import="com.damaris.ldsweb.*,com.damaris.data.*,com.damaris.page.*,java.util.*"
  18. %>
  19. <html>
  20. <head></head>
  21. <body>
  22. <IMG src=<%=request.getContextPath()%>image.jsp>
  23. </body>
  24. </html>
  25. // my 2nd JSP
  26. <%@page
  27. language="java"
  28. errorPage="errorpage.jsp"
  29. import="com.damaris.ldsweb.*,com.damaris.data.*,com.damaris.page.*,java.util.*"
  30. %>
  31. <html>
  32. <head>
  33. <%
  34.     // pageToPrint is an instance of the class "Page" (getContentType ( ) give the String "image/tiff" )
  35.     response.setContentType(pageToPrint.getContentType ( ));
  36. %>
  37. </head>
  38. <body>
  39. <%
  40.     ServletOutputStream bOut = response.getOutputStream();
  41.     pageToPrint.write (bOut);
  42. %>
  43. </body>
  44. </html>


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)