How to show gif attachment in jsp

now the MimeMessage has a MultipartBody containing a gif picture,how can I show it in
jsp? only just using this code does not work:
BodyPart p=/*get the MultipartBody;*/
p.getDataHandler().writeTo(respone.getOutputStream());
out.flush();

You have to set the content type on your response firts.
eg; response.setContentType("image/gif");

Similar Messages

  • How to show an image in JSP given the bytes[] of the photo?

    Hi all,
    I stored a user's picture in the db as text. For this I simply converted the JPG to bytes[] and from bytes to string: Base64.encode(bytes)
    Now I wish to do the reverse - to 'output' the image on the screen. So given the bytes[] of the image with
              byte[] bytesDB = Base64.decode(userPhotoStr); //userPhotoStr is something like this: /9j/4AAQSkZJRgA...Question: How can I show the image in the JSP page embedded in the page not as download?
    I'm using struts with JSP pages.
    Thank you!!!!

    Images in HTML are to be displayed using <img> element. All what an <img> element can take as image is an URL pointing to the image in question.
    If the image is dynamic, then you can just let that URL point to some Servlet which takes some request parameter or reads the path info, reads/gets the image as byte array or (much more efficient) as inputstream and writes it to the outputstream of the response.
    You may get some ideas out of this: [http://balusc.blogspot.com/2007/04/imageservlet.html].
    By the way, massaging the byte array from/to a String is a terribly bad idea. Just store bytes as computer readable bytes, not as human readable characters, this makes completely no sense. Characters on its turn have to be converted to bytes again after all, but now you've let the DB do the work. All with all a performance pain. Bytes > Chars > Bytes > Chars > Bytes instead of just Byes > Bytes. In database you normally use BLOB, BINARY or equivalent for this in combination with JDBC's PreparedStatement#setBinaryStream() and ResultSet#getBinaryStream().

  • How to show database data in jsp page?

    actually i m doing a small appliaction of quiz test.
    where i m keeping my question and answers in the database.
    now i want to pull questions from the database and display in the jsp or html page.for each question i m having 4 options 4 them.
    like this user has to answer the question and display the resuklt in the end.
    so how can i do this?
    can i get any example or source code for this from any sites?

    Hope this will be ur assignment. Pls try to start ur assignment and post ur doubts with ur code. So that some one can help u.
    Cheers.

  • Urgent Help Please..How to show an alert in jsp if servlet has an exception

    Hi
    I am calling a servlet from popup jsp.
    When the values are submitted from the jsp I am calling the servlet where i have functionality to send an email. But if email fails in the servlet I have to return to the popupjsp and show an alert to the user.
    If any body knows please help.
    thanks in advance.

    Hi,
    Do like this :
    In the servlet's doPost() method, add codes in the manner
    mentioned below.
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
    PrintWriter out = response.getWriter();
    try{
    //throw new Exception();
    catch(Exception ex){
    out.println("<html><body>");
    out.println("<script language='javaScript'>");
    out.println("alert('Exception Occured Servlet...');</script>");
    out.println("</body></html>");
    Hope it helps.
    Regards,
    Sudhir

  • How to show simple chinese in jsp

    when I use simple chinese in jsp,in the portlet all the char convert into B>B-C&#147;B*B;C.B6B/,but in the servlet,all the simple chinese char it right,I have set the conentType = "text/html;gb2312",but the problem is still.
    somebody can help me!
    thanks!

    You have to set the content type on your response firts.
    eg; response.setContentType("image/gif");

  • How to show JTree on html,jsp

    Any help?What to use JFrame, scrollpane or what?
    Thanxs

    1. You could use an applet
    2. You could transform your JTree into javascript

  • When I get a email of a picture from a cell phone on my ipad 2 it just says I have recieved a multimedia message. It does not show n attachment or anything. I have tried using adobe and all tons of stuff. How can I the attachment to show up?

    When I get n email from. Cell phone that's a picture the email says I have a multimedia message but, that's all. It won't show an attachment or anything. I've tried opening the email in adobe and everything. How can I get the attachment to show? Please help.

    You did not get an email, you got a MMS. You have to enable MMS on your phone before you can see the picture.
    http://en.wikipedia.org/wiki/Multimedia_Messaging_Service

  • How to add an attachment to an e-mail. With out it showing  up and the end of a e-mail.

    How to add an attachment to a e-mail. With out it showing up at the end of the e-mail.

    https://discussions.apple.com/message/17397882#17397882
    How can I prevent mail attachments embedding when sending mail
    Note there are 14 pages of replies

  • How to show image in a Transperent form ?? screen shots attached

    Hi
    Help me in making Images appearing as Transperent . Screen shots attached
    I am having a TextInput and a Search Button (The Functionality is that user can enter something in this TextInput and makes a Search Operation by pressing Search Button .)
    At the Initail screen display i need to show Some Image in transperent  Inside this TextInput  , when Mouse is focused on this TextInput , the Image will be completely Invisible .
    Now the question i want to ask is , how to show image in a Transperent form ??
    Please find the screen shots attached with this Thread .

    Thanks for specifying  the alpha property of an Image .

  • How to show chinese char form db in my jsp portlet?

    How to show chinese char form db in my jsp portlet?
    I had tried to set contentType in renderResponse, but itn't work ..

    Bent,
    You can access the database from your Java portlet, just like from any other Java/JSP environment. Yes, you can use JDBC, as well as BC4J.
    The Discussion Forum portlet was built using BC4J, take a look at it's source to see how it was done.
    Also, check out Re: BC4J Java portlet anyone?, it contains a lot of useful information too.
    Peter

  • How to show a picture from my database (BLOB field) Oracle into my JSP

    Hi all, i got a problem trying to show a picture in my JSP.
    I have a servlet which loads my picture, the problem is that i dont know how to set into a session// session.setAttribute("xxx","aaa") // or if there is another way to set it up, in order to show it in my JSP, if someone could help me i really appreciate it... thanks

    The way you include it in your jsp is the standard way you download any image.
    With an image tag
    <img src="myImageServlet?imageId=42"/>
    and your imageServlet actually returns the picture via its output stream.
    ie it makes 2 requests. One for the jsp page, and then when it receives and parses the html, one to the servlet to get the image.

  • How can i show gif files through reports

    I have blob column in a table and i store text with some gif files there ...i made a report for that and i set the property of blob item like ..file format as "text" and containes html tags "yes" then i generate the report on html but when i see the on html i can see only text not any picture like .gif file ..
    if any body have the solutuion to show .gif files with text then tell me ...
    Thanx..

    hello,
    you say, you store text with gif images in a blob. the question would be, in what format. if you store HTML text there, the images are actually not stored in the document but only references to them. you might then check the src attributes of your IMG tags if they point to valid destinations.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to communicate between Flex and JSP and show the result in an Iframe

    Hi all
    I am trying to send some data from flex to one HTTPService and trying to show the same response jsp in an Iframe. But unfortunately i am unable to get the responce Jsp's url to set as a source for iframe.
    let me explain you clearly...I have a mxml where i am having a text box and a button in the left panel and in the right panel i am having an Iframe to display jsp. So once user enters some value in the text box and clicks button then HTTPservice's send method will be called with text box's content as an arguement. So i can fetch that value from request object in jsp and display the value in jsp. So the problem here is i want display that result jsp in my Iframe. I know that , we need that result jsp URL to display in Iframe . But as i am sending POST request to HTTPservice, i am not able to get the result jsp's URL in flex side.
    So i need help desperately from great minds.So anyone of you can give me some suggestions!!!!
    Regards

    Hi all can some one please give a solution ...Any suggestions would be greatly appreciated

  • How to show modal window without popup in a web page using javascript

    Hi,
    How to show modal window without popup in a web page using javascript, means when the modalwindow is opened it should not ask for popup blocker alert......
    pls help me.....

    Thanx for ur reply,
    Actually the senario is when i click on a button, another jsp page should be displayed in a modal window without popup, but the functions alert() and confirm() will not accept the url path of the another jsp page...

  • How to show Popup window in OAF on click of a button

    How to show Popup window in OAF on click of a button (Without using Javascript)
    1. I have one OAF page on which i should have button Called "Next"
    2. On clicking of this button a new window/page should be displayed with the image stored in database. on clicking on this "Next" button again next image from the database should be displayed on the newly opened window/page.
    3. Is it possible to configure OAF to render window_II in the opposite screen of window_I where the OAF client resides? (If the OAF-client resides in screen_I render window with image in screen_II). That is, at the first click on the Next-button, window_II appers on screen_II and not some random location. The user will have 2 screen/monitors on his work place.
    4. Given that the two windows reside on each screen, is it possible to make OAF remember the position of window_II ? The goal of this is to force the window to pop up on the same location on the same screen next time the Next-button is pressed.
    5. If window_II is closed (eg. by using X) and the Next-button in window_I is pressed again, will window_II pop up in the same location and screen as previously ?
    6. Is it possible to have a Print-button in window_I what prints the scanned picture in window_II ? Is it possible to have the click on this Print-button to open the standard print dialog on top of window_II ? Could the button be placed in window_II as well, having the same functionality ?

    I have tried to open home page window. You can change the URL according to your requirement.
    import oracle.apps.fnd.framework.webui.OAUrl;
    StringBuffer l_buffer = new StringBuffer();
    l_buffer.append("javascript:mywin = openWindow(top, '");
    String url = "/OA_HTML/OA.jsp?OAFunc=OAHOMEPAGE"; // Calling Oracle Home Page
    OAUrl popupUrl = new OAUrl(url, OAWebBeanConstants.ADD_BREAD_CRUMB_SAVE );
    String strUrl = popupUrl.createURL(pageContext);
    l_buffer.append(strUrl.toString());
    l_buffer.append("', 'lovWindow', {width:750, height:550},false,'dialog',null);");
    pageContext.putJavaScriptFunction("SomeName",l_buffer.toString());
    Above code will open the new page in new window.
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for