How to put Download Links on a Jsp Page?

Hi,
I am a student and I am working as an intern. This is my question:
My boss wants me to put some download links(pdf and flash files) on to a jsp page. when a user clicks on the link, all the user info (i.e. name, filename, download time etc) should be stored in a database and then a pop up should appear asking user where you want to download the file.
I have done most of the part but there is a problem. when a user "left click" on the link then it opens the PDF file in the browser. but if the user "right click and select save target as" then it brings up the box. My boss dont need the user to VIEW the file by left clicking it. I mean on both clicks a pop-up box should appear.
one more thing to note is that, the PDF are not on the same server. I mean they do not have the same context path.
Here is what I am doing:
on the link page:
sample
on the other page (which stores information):
// ... this is downloadfile.jsp
response.setContentType("application/force-download");               
String filename = request.getParameter("file");          
String path = "http://www.domain.com/pdf/" + filename;
bean.addDownloadDetails(session.getAttribute("email").toString(), filename, request.getRemoteAddr());  // save info in database
response.sendRedirect(path);
// ...any ideas or help is appreciated.
Thanks.

Straight to the question in the topic title: just use <a> links. But you already found that out. In the future please invent clear topic title covering the actual problem :)
I have done most of the part but there is a problem. when a user "left click" on the link then it opens the PDF file in the browser. but if the user "right click and select save target as" then it brings up the box. My boss dont need the user to VIEW the file by left clicking it. I mean on both clicks a pop-up box should appear.Change the content disposition to "attachment" instead of "inline".
one more thing to note is that, the PDF are not on the same server. I mean they do not have the same context path.
Here is what I am doing:
// ... this is downloadfile.jsp
response.setContentType("application/force-download");               
String filename = request.getParameter("file");          
String path = "http://www.domain.com/pdf/" + filename;
bean.addDownloadDetails(session.getAttribute("email").toString(), filename, request.getRemoteAddr());  // save info in database
response.sendRedirect(path);
// ...any ideas or help is appreciated.
Thanks.Better obtain its InputStream by java.net.URLConnection and write it to the OutputStream of the HttpServletResponse. A redirect would create a brand new request, hereby dropping the current request and the response (so setting the content type makes really no sense).
You can find some pointers in this FileServlet example: [http://balusc.blogspot.com/2007/07/fileservlet.html].

Similar Messages

  • How do i download Oracledata comming to jsp page finally to excelsheet

    Hi if anyone can know ,let me know how i will download oracle data comming from oracle and then i it have to come to jsp page.it need to download as microsoftexcel sheet.any one can help me out will be great.

    I had a similar problem long back how to convert ... There was a package available from alphabeans.ibm.com try searching for that java bean which helps u out

  • How to place download link on jsp page to download files eg. Download PDF

    Hi,
    I have made an appliaction in struts 2 which creates PDF,its working fine now i want to place a link on my jsp page from where i can click and download that PDF file which i have created and store on my local location. Also i want to to know can i place links on my jsp page to download other type of files if i want to give link on my page to download Images or songs how can i do that,
    Help plzzzzzzzzzzzz

    IF You are using jsf then simply <h:outputLink value="file:///D:/Me/Image000.jpg"/>. This generates HTML <a> tag and value attribute replacing with <a> tag's href attribute.If you are using other technologies try to find which tag generates HTML <a> tag.
    I think You also can simply place HTML <a> tag wherever You want

  • How can I link to a jsp page from another jsp page within websphere portal?

    Afternoon all,
    I have a websphere portlet which displays a jsp page. I want to put a hyperlink on the jsp page which when clicked will open another jsp page.
    Does anyone know how to do this?
    Thanks,
    Alex

    The anchor tag is the correct one for generating clickable links.
    <jsp:forward> is for transferring control at the server end. Its when you decide to change which page you want to show the user. ie check user is logged in. If not then forward them to login page, else display current page.
    I tried that. It does open the jsp page
    but the place and page links in the portal theme get screwed up.Whats mucked up about them? Do they point where they shouldn't?
    You might try using a <base> tag to set where relative links are resolved from.
    Cheers,
    evnafets

  • How to make downloadable links in Adobe Muse

    I am new to website design and am trying to figure out how to make downloadable links for some PDF flyers, PSD templates I am creating.   Not sure if "downloadable links" is the correct term for what I'm trying to say but in a nutshell I am creating Business Flyer's in PDF form and Photoshop PSD template files that I would like to be able to have my users click a link that allows them to download them right to their desktop.  Any help would really be appreciated!

    Hi caybar10gaming,
    I had the same question as you and was searching online for how to add "downloadable links" as well so your not alone in that lol. Anyways, I found this video that explains how to do this. I hope this helps you, as it did me. Good Luck  
    http://tv.adobe.com/watch/muse-feature-tour/add-and-link-to-any-type-of-file/
    -Caitlin

  • How to put the trace messages in JSP DynPage

    Hi,
    How to put the trace messages in JSP DynPage components. What settings I need to do and where do I see the trace log.
    Can I also print the values of some variables in trace. If yes, how to achieve this?
    Thanks in advance,
    Regards,
    Madhu

    Hi Madhu,
    for NW04 see http://help.sap.com/saphelp_nw04/helpdata/en/e2/75a74046033913e10000000a155106/frameset.htm
    as well as
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/using logging and tracing on the sap web as java.pdf
    Hope it helps
    Detlev

  • How to generate download links of packages through Pacman

    Hello World
    I have installed Arch base in virtual box before physical install. I have synchronized pacman database with pacman -Syy command. Now I want to install other stuff like x ,gnome, sound etc. Please tell me how to generate download link for any any package and all its dependencies to a text file with Pacman so that i can download it with wget on some other computer and then transfer it back to my system.
    Thanks
    Last edited by cadcrazy (2008-09-23 03:33:08)

    man pacman wrote:-p, --print-uris
               Print out URIs for each package that will be installed, including
               any dependencies yet to be installed. These can be piped to a file
               and downloaded at a later time, using a program like wget.

  • How do i use Connection pool in JSP pages

    Hey everyone,
    I am using a connection pool in my web application. I am using DbConnectionBroker from Javaexchange.com. It has a class that creates a connection pool available for the servlets. I am trying to figure out that how to use connection pool within the JSP pages if I want to connect to the database. In the servlets i am using DBConnectionBroker pool = (DbConnectionBroker) getServletContext().getAttribute("dbPool") to get database connection. How Can i use this in JSP page to get a db connection.
    Thanks

    If the reference to the connection pool is already stored as an ServletContex attribute, try:
    <jsp:useBean id="dbPool" scope="application" class="com.javaexchange.dbConnectionBroker" />
    <%
    Connection con = dbPool.getConnection();
    %>

  • HOW TO PUT TWO PANNEL IN THE SAME PAGE

    HI ALL
    I NEED TO KNOW HOW TO PUT TWO PANNEL IN THE SAME PAGE TO FULLY UTILIZE FULL PAGE AREA BECAUSE THE PANNEL WIDTH IS TOO SMALL , SO I WANT TO MAKE THE PAPER CONTAIN TO PANNELS VERTICALLY.
    THANK YOU

    So Barb,
    I like to use multiple desktops and move back and forth between then using gestures. At the moment I have 5 open: Chrome, Firefox, Safari, Photoshop CS 6 and a desktop. I use "gestures" to navigate between them:
    Mac Basics: Multi-Touch gestures - Apple Support
    and I use Mission Control (F3) to move the various desktops around in the order I want them.
    Mac Basics: Mission Control - Apple Support
    So say I'm searching for a photo to open in CS 6, I find it on the open desktop then hit select "open" in CS 6 and go to that folder in the select pane.
    Even right now I'm typing this in Safari and "gesturing" back to Chrome where I did the search about multi touch and mission control. I drag copy the URL there  and gestured back here to paste the URL into this text.
    If you did a lot of photo searches, I set professional clients of mine in Chicago up with dual monitors (In this case you'd have an external monitor on extended desktop.). So all you need to do is just glance over at the second monitor slide your cursor over there open stuff up find your photo and go back to Photoshop and open it up.
    Hope this helps.

  • Using hyper-links in a jsp pages that are in a Session

    Hi i am trying to include a hyper-links in my jsp pages that are in a Session, however when i use the links to navigate throughout the pages i get a java.lang.NullPointerException. The Session begins after the user has been validated i.e
    String cid= request.getParameter("counsellorID")
    session.setAttribute("counsellorID",cid);
    All the pages included within the session have a session scope=session
    ; and they call the attributes that have been set when the session first begins i.e
    String counsID= (String) (session.getAttribute("counsellorID"));
    Any advice on this problem would be most appreciated!
    Many Thanks
    Stephen

    check if you borwser have cookies enabled

  • How we can generate dynamic menu in jsp page

    Hi all,
    how we can generate dynamic menu in jsp page.
    Thanks
    Manjinder

    by reading more about them on the web or in a good book, OR BY HIRING SOMEBODY TO DO SO. ;)

  • HOW to send a value to another jsp page

    HOW to send a value to another jsp page, like user name in one jsp page to another jsp page

    In the most simplest form...
    // pageA.jsp
    <html>
    <body>
    <form action="pageB.jsp" method="post">
    <b>First Name:</b> <input type="text" name="FNAME" value="Joe">
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    // pageB.jsp
    <html>
    <body>
    <b>Name:<b> <%=request.getParameter("FNAME")%>
    </body>
    </html>

  • How to put multiple photos on 1 A4 page

    Hi
    Can someone tell me how to put multiple photos on 1 A4 page,
    many thanks

    Try this:
    File >> New
    Set your width and height dimensions of A4 in mm.
    Set resolution e.g. 72 for web use/email or 240-300 for printing.
    Set background color to white (or whatever you prefer) and click OK
    Now get your first image
    File >> Place Embedded
    Select your first image and click place
    Drag to position and scale with the corner handles whilst holding down Shift.
    Click the check-mark to commit.
    Repeat for each of your other images.

  • How to display download link with get_blob or get_blob_file_src ?

    Hello there,
    I am struggling to display a download link in a SQL query report.
    Based on the requirement, I have to create a sql query report that the source contains a series of union select query.
    Example here
    WITH current_engagement AS (
    SELECT defendant_id, engagement_id, pn, ethnicity, date_joined_aodt_court, case_manager_name
    , participation_conditions, discharge_conditions
    FROM engagement
    WHERE defendant_id = :PXX_DEF
    AND date_joined IS NOT NULL
    AND ( date_terminated IS NULL OR to_date(date_joined,'DD/MM/YYYY') > to_date(sysdate,'DD/MM/YYYY'))
    AND active = 1 AND ROWNUM = 1
    ORDER BY defendant_id DESC
    SELECT def.first_name, def.middle_name, def.surname, to_char(def.pn) AS "PN", to_char(def.nhi_number) AS "NHI"
    ,ce.ethnicity, to_char(ce.date_joined) as "DATE_JOINED ", ce.case_manager_name, ce.participation_conditions, ce.discharge_conditions
    FROM defendant def INNER JOIN current_engagement ce
    ON def.def_id = ce.defendant_id
    UNION ALL
    select ' <b>2. Phase Number</b>' , '<b>Date Started</b>' , '<b>Date Finised</b>' , '<b>Notes</b>' , null
    ,null , null , null , null , null
    from dual
    UNION ALL
    SELECT TO_CHAR(NVL(ph.phase_number,'No Phase Found')), TO_CHAR(ph.date_started, 'DD/MM/YYYY'), TO_CHAR(ph.date_finished, 'DD/MM/YYYY'), ph.notes, null
    , null , null , null , null , null
    FROM phase_membership ph INNER JOIN current_engagement ce
    ON ph.mpm_eng_id = ce.engagement_id
    WHERE to_date(ph.date_started,'DD/MM/YYYY') <= TO_DATE(sysdate,'DD/MM/YYYY')
    AND ( ph.date_finished IS NULL
    OR TO_DATE(ph.date_finished, 'DD/MM/YYYY') >= TO_DATE(sysdate,'DD/MM/YYYY') )
    AND ph.active = 1
    UNION ALL
    --more selects
    -- then the last select is to list all related documents with download links
    select '<b>6. Document Date</b>' , '<b>Document Type</b>' , '<b>Description</b>' , '<b>Download</b>'
    , null ,null , null , null , null , null
    from dual
    UNION ALL
    SELECT TO_CHAR(doc.date_received), doc.document_type, doc.comments, TO_CHAR(dbms_lob.getlength(doc.UPLOADED_FILE))
    , null ,null , null , null , null , null
    FROM document doc INNER JOIN current_engagement ce
    ON doc.d_eng_id = ce.engagement_id
    WHERE doc.active = 1
    This report is generated fine.
    But the requirement also ask to display a download link. And because it is union selects, all following selects must be the same as the first select column data types.
    In this case, it has to be CHAR. Otherwise, it will generate error as below
    ORA-01790: expression must have same datatype as corresponding expression
    So I follow the GET_BLOB_FILE_SRC Function step from
    http://docs.oracle.com/cd/E14373_01/apirefs.32/e13369/apex_util.htm#AEAPI129
    I turn my last select into
    SELECT TO_CHAR(doc.date_received), doc.document_type, doc.comments,
    CASE WHEN NVL(dbms_lob.getlength(doc.UPLOADED_FILE),0) = 0
    THEN NULL
    ELSE
    'Download'
    END
    , null ,null , null , null , null , null
    FROM document doc INNER JOIN current_engagement ce
    ON doc.d_eng_id = ce.engagement_id
    WHERE doc.active = 1
    Which the result inside the hreg is
    http://app_address_here/f?p=208:48:1303335952329758:::::
    while if I use Interactive report the link is
    http://app_address_here/apex_util.get_blob?s=1303335952329758&a=208&c=66645817090447568&p=48&k1=12&k2=&ck=A18D20D407435BD649EA3399EC27BC00&rt=CR
    and it works well.
    I do a research and know that get_blob_file_source link to the source of the column / field name located in the first parameter.
    So I had put the UPLOADED_FILE column, DOCUMENT table in the source of the column PN.
    But it still does not show anything that close to the correct one that is generated by interactive report.
    If anyone has any ideas, please help. If I need to manually write using get_blob , please give me an example.
    I urgently need to do this report.
    The version of APEX we use is Application Express 4.0.2.00.07
    And I cannot ask for an upgrade to 4.2 till the end of next year.
    Please help.
    Thanks a lot in advance.
    Ann.

    Hi Ann,
    Here you can see and download the example :
    http://apex.oracle.com/pls/apex/f?p=63066:1
    Please let me know if you need access the work space.
    Hint, Please read the FAQ section. had you put your thread in a better format, you would have gotten a quicker response :)
    Regards,
    Fateh

  • How do I reinstall Photoshop? No download link in My Products page

    I bought Photoshop Extended back in early 2013, but my computer suffered a severe virus and had to be completely reset with a new copy of Windows. For a while I completely forgot to reinstall Photoshop, but now I have a college class that requires it. Unfortunately the My Products page has no download link even though it shows I've bought it. I would greatly prefer not to have to buy another copy on my measly student budget, so how do I redownload the one I have? None of the direct download links I've seen have my version of Photoshop.

    Downloads available:
    Suites and Programs:  CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4 | CS3
    Acrobat:  XI, X | 9,8 | 9 standard
    Premiere Elements:  12 | 11, 10 | 9, 8, 7
    Photoshop Elements:  12 | 11, 10 | 9,8,7
    Lightroom:  5.6| 5 | 4 | 3
    Captivate:  8 | 7 | 6 | 5
    Contribute:  CS5 | CS4, CS3
    Download and installation help for Adobe links
    Download and installation help for Prodesigntools links are listed on most linked pages.  They are critical; especially steps 1, 2 and 3.  If you click a link that does not have those steps listed, open a second window using the Lightroom 3 link to see those 'Important Instructions'.

Maybe you are looking for