Viewing HTML page saved  on the server from the browser

Hi all
In my application i am having some HTML pages saved on the server. I had given an option to the user to view the HTML page from my application. behind the scene what i am doing is that the view request will get handled by a servlet and from that servlet iam locating the HTML page on the server directory and sending the HTML page to browser by using the Servlet OutputStream. The HTML page is shown on the browser but the attached images are not shown. The images are also there in the server directory and are refered in the HTML file correctly. When i directly open the HTML file then the images are shown correctly.
Can anyone suggest wat's wrong there.
The code i m using is
ServletOutputStream out=response.getOutputStream();
                    if(format.equalsIgnoreCase("pdf"))
                         logger.info("Seleted format is pdf..\n");
                         response.setContentType("application/pdf");
                    else
                         logger.info("Seleted format is html..\n");
                         response.setContentType("text/html");
String file = ReportingConstants.URL_GENERATEDREPORTS+reportPath+itemName;
// file : HTML file absolute path as string.
                    URL url=new URL(file);                    
                    BufferedInputStream bis=new BufferedInputStream(url.openStream());
                    BufferedOutputStream bos=new BufferedOutputStream(out);
                    byte[] buff = new byte[2048];
                    int bytesRead;
                    while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
                         bos.write(buff, 0, bytesRead);
                         bos.flush();
                    }

You have to undertsand how the browser handles images and other resources in a HTML page. In the HTML there is an image tag that has a url to an image which can be a reletive url or an absolute url (starts with a "/").
If the url is a relative url the browser interprets the url as being relative to the url currently displayed in the address field discarding the last element of the url . So if the url in the address bar is http://www.myserver.com/myapp/mypage.html and the relative url is images/myimage.jpg, the browser will submit a request to the server for http://www.myserver.com/myapp/images/myimage.jpg
Now let's say that you are call mypage.html from a servlet that has the url http://www.myserver.com/myapp/servlets/myservlet. Then when the browser tries to retrieve myimage.jpg it will use the url http://www.myserver.com/myapp/servlets/myservlet/images/myimage.jpg and since this is incorrect it will not be able to display the images.
One solution to this is to change all of the image urls to absolute urls. That is the start with a slash where the slash represents the start of the url after the application domain name. For example you used an absolute url for myimage.jpg it would look like /images.myimage.jpg and when accessing the page through the servlet url (http://www.myserver.com/myapp/servlets/myservlet) the browser will discard everything after http://www.myserver.com/myapp and look for the image at http://www.myserver.com/myapp/images/myimage.jpg which is the correct url.
A second solution is to use the HTML BASE tag which tells the browser not to interpret the image tag urls (and other resourses) using the current url in the address bar but to use the url supplied in the HTML BASE tag. The browser will still perform the same process for relative urls but now relative to the BASE tag url. Since the BASE tag url will be the same every time the page is accesssed the images should be correctly accessed no matter how the page is accessed (eg directly, using RequestDistpatcher or via your servlet)

Similar Messages

  • I have a Mac on my home network and also a Systemline music server on same network. My PC was able to find the server but my MAC cannot. I can ping the server from the mac, but cannot actually connect . Also can't add the mac as a location from server

    I have a Mac on my home network and also a Systemline music server on same network. My PC was able to find the server but my MAC cannot. I can ping the server from the mac, but cannot actually connect . Also can't add the mac as a location from server, despite following the Systemline instructions that impy this can be done.
    Can anyone please advise what I am doing wrong?

    Hi LowLuster
    Thanks for reply. I am not an expert on these sharing protocols but I think I have turned on SMB sharing but still wont connect. I tried adding netwrik drive by using cntrl K in finder and using smb\\network address but nothing. It is driving me mad!!

  • TS1402 I can not copy any files from the server & from the Finder. System MAC OS 10.7.5

    I can not copy any files from the server & from the Finder. System MAC OS 10.7.5
    <Email Edited by Host>

    Hi, what is the no boot directory found about???
    Can you give details step by step of what you're trying?

  • Calling a remote program on the server from the client

    Hi, I'm new to Java/Jdeveloper/Oracle I'm writing a small app in
    Jdeveloper 3.2 running on Windows that connects to an Oracle
    8.1.6 on a Redhat Linux. I have a few programs writen in C that
    run on the server, and would like to call them from the client
    machine with a few parameters. is there a way of doing that?
    it's just like calling "ls -la filename" from the remote
    client. BTW, I don't need to get a response from the server, I
    just need to initiate the call.
    Thanks for any help.
    John

    JDeveloper is an IDE not a platform. what sort of app are you
    writing: client server application, applet, JSP?
    APC

  • How do I gracefully shutdown the server from a script?

    I have a shutdown class that stop the server.
    When I'm using 'stop the server' from the console (after configure a
    new shutdown class to config.xml) it work good.
    How do I do the same from a script (cmd, bat or sh - doesn't metter).

    http://edocs.bea.com/wls/docs81/ConsoleHelp/startstop.html#1212202
    "avishosh" <[email protected]> wrote in message
    news:[email protected]..
    I have a shutdown class that stop the server.
    When I'm using 'stop the server' from the console (after configure a
    new shutdown class to config.xml) it work good.
    How do I do the same from a script (cmd, bat or sh - doesn't metter).

  • Starting a WSAD server from the command prompt and not from the IDE UI

    Hi,
    is there a way to run the WSAD server from the command prompt instead of using the IDE UI . i have tried starting the server from the Directory i have installed WSAD " D:\Program Files\IBM\WebsphereStudio\runtimes\base_v5\bin>startServer.bat" but it gives the Following error " The system cannot find the path specified." i am working . do i have to specify the workspace that i am currently working on

    to see if the network adapter has registered with OPMN run: opmnctl status
    the 6200 message is a timeout which can be set in opmn.xml, the reports server(s) and other processes managed by OPMN should still stop.
    Try opmnctl stopall or opmnctl shutdown
    Does the timeout shows up regularly ie can you repeat it?
    After the stopall or shutdown try to start everything up again and try to stop the single reports server process again.

  • How can i Use the symbols from the main html page?

    Hello!
    Im trying to find a solution for days!!
    i need to use my symbols from the html page, for example to hide the symbol i want to use: sym.$( "sym1" ).hide(); or to make it draggable (with jquery UI) i wanna use: sym.$( "sym1" ).draggable(); but it doesn't work.
    i know i can do the same from the edgeActions.js file and here is the working code:
          Symbol.bindElementAction(compId, symbolName, "document", "compositionReady", function(sym, e) {
             var ex1 = sym.$( "farmer" );
             //ex1.html( '<input type="text" />' );
             yepnope({
                 both: [
                     "libs/jquery-ui.min.js",
                     "libs/jquery-ui.css",
                 callback: function() {
             ( ex1 ).draggable();
    but the main problem is that it's always include this file as the very last .js, so in case Im trying to use the symbols from the index.html page (For example:  ( ex1 ).draggable();  ) the variables are undefined (because it read the html first)...
    Please Help, Im desperate..
    Thank you very much!!!
    Eran

    Hi, Eran-
    You will want to use the AdobeEdge.* APIs, which should give you access from external JavaScript into your Edge Animation.  The API document has information on that.  However, you will need to wait until the runtime loads, so you should use the bootstrapping method that is outlined in Josh Hatwich's post on our blog:
    http://blogs.adobe.com/edge/2012/05/15/bootstrapping-edge-compositions/
    Hope that helps!
    -Elaine

  • What is the easiest way to get the data from the mailmerge to form Pages files that can be saved separately?

    Using Iwork 09 I have spent several hours setting up a mail merge from a spread sheet in Numbers to create receipts for my customers from a Pages template.
    After the merge I am left with one long Pages document that will not save as separate files; one per customer, it will only save the whole document of several receipts.
    What is the easiest way to get the data from the mailmerge to form Pages files that can be saved separately?
    Many thanks in advance.
    Richard

    Mr. Clark,
    You will probably be more pleased with the iWork apps when you begin to learn your way around. Until you learn such basic things as how to print only one page of a document, you will probably continue to be disappointed.
    Does your Print dialog look like this:
    Or like this:
    If it looks like the first one, then you will want to click this expander control:
    Regards,
    Jerry

  • URGENT-CREATE A HTML FILE WITH AN STRING INPUT FROM THE RUNNING JSP

    I am designing a web page where the user enters a page after entering his/her login and password.The User should now be provided with a display page containing the servers that he has permissions for access.The servers that he has permissions are maintained in a database(a normal text file in UNIX).
    Till now the program has been complete for displaying the servers that are available to him.
    I need to create a HTML form containing these servers names in a check box so that when the user clicks thcheck box against the server name it should go to the server and get the password for the required server.
    THe intention from me is to create a HTML file that dynamically takes values from the running JSP means the server names as a string value to its input and then i can continue
    Please guide me in creating a HTML form based on the string output from the running JSP
    FileInputStream fs = new FileInputStream("/root/Auth_Application/User_Access_List");
    DataInputStream in1 = new DataInputStream(fs);
    int fl=0;
    while (in1.available() !=0)
    String str1=in1.readLine();
    StringTokenizer st1 = new StringTokenizer(str1);
    String usernam=st1.nextToken();
    if (usernam.equals(uname))
    String ip=st1.nextToken();
    String host=st1.nextToken();
    fl=1;
    out.println("<tr><td>                                                                                              "+ host + "</td><td> " + ip +"</td></tr>");
    if (fl == 0)
    out.println("YOU HAVE NO SEVRER IN YOUR PROFILE !");
    in1.close();
    The host string here is the server name
    the ip is the ip address of the server
    Need to input these values to another HTML page that contains the check box list of the servers .
    once these are clicked i think i can pass on this to another JSP and retreive passwords
    Please guide me in this

    FileInputStream fs = new FileInputStream("/root/Auth_Application/User_Access_List");
                                    DataInputStream in1 = new DataInputStream(fs);
                                    int fl=0;
                                    while (in1.available() !=0)
                                    String str1=in1.readLine();
                                    StringTokenizer st1 = new StringTokenizer(str1);
                                    String usernam=st1.nextToken();
                                    if (usernam.equals(uname))
                                    String ip=st1.nextToken();
                                    String host=st1.nextToken();
                                    fl=1;
                                    out.println("<tr><td>                                                                                              "+ host + "</td><td>          " + ip +"</td></tr>");
                                    if (fl == 0)
                                    out.println("YOU HAVE NO SERVER IN YOUR PROFILE !");
                                    in1.close();I feel sorry for the inconvenience that is caused as i am new to using these forums.
    I have here used a simple program to retreive the names of the servers that the users have acess to..
    I have here read the servername and server ip stored from a file in UNIX in the running JSP.Now i need to pass these string variables to HTML file and display it in a Check box format.the strings host and ip have to be passed to the input of the HTML file so that they can further be processed once they are clicked using another JSP.
    Can anybody please help me in Passing these strings from the running JSP and display it in a check box format

  • How to find out the user from the Jobs queue in Report server

    Hello All!
    I have a doubt about finding out the user from the scheduled jobs queue. Say I go ahead and schedule a report on Reports Server how can I find out the user name. When I view the jobs using showjobs I could see that the DBMS_JOBS table has a column under "Job Owner". But it invariantly shows it is "rwuser". So is there a way to find out which user has scheduled which job?
    Regards
    Shobha

    hi,
    The below tables will give only the name .
    USER_ADDRS
    USER_ADDR
    USER_ADDRP
    USR02
    i think you need email address .
    you can use this Tcode : su01d
    and give the user name and excute it
    i hope it will help you.
    Ram
    Edited by: Ram velanati on Jun 30, 2008 6:57 PM

  • Error while accessing a file located in the server from JSP

              Hi
              I am having problem while accessing the file located in the server from a JSP
              page. I am not getting the RealPath from a JSP page using getRealPath(request.getServletpath()).
              The same code is working if the jsp placd under defaultwebApp directory and not
              working if i create a war and deploy the same.
              I am using weblogic server 7.0 trail version.I am setting the context path also.
              Can any help me in this regard.
              Thank And Regards
              Anand Mohan
              

              Hi
              Thank you.Is there a way to read a file which is existing in the war file.
              Regards
              Anand Mohan
              "Wenjin Zhang" <[email protected]> wrote:
              >
              >In Weblogic, if your files are archived in a WAR, you cannot get an entry
              >as individual
              >file since it is only bytes in a large archive file. So getRealPath will
              >give
              >you null result. If you only want the path, try to use other getXXXPath,
              >getURL,
              >or getURI method. If you want to read the content, use getResource.
              >
              >
              >"Anand" <[email protected]> wrote:
              >>
              >>Hi
              >>I am having problem while accessing the file located in the server from
              >>a JSP
              >>page. I am not getting the RealPath from a JSP page using getRealPath(request.getServletpath()).
              >>
              >>The same code is working if the jsp placd under defaultwebApp directory
              >>and not
              >>working if i create a war and deploy the same.
              >>
              >>I am using weblogic server 7.0 trail version.I am setting the context
              >>path also.
              >>
              >>Can any help me in this regard.
              >>
              >>Thank And Regards
              >>
              >>Anand Mohan
              >
              

  • The document could not be saved. The server said: "The operation failed because an unexpected error occurred. (Result code 0×80020005)" Please ensure you have completed all required properties with the correct information and try again.

    I am having problems  saving documents back to SharePoint when any of the document properties (metadata columns) are set to be "managed metadata". The check-in/save fails with error:
    The document could not be saved. The server said:
    “The operation failed because an unexpected error occurred. (Result code 0×80020005)”
    Please ensure you have completed all required properties with the correct information and try again.
    I have seen similar threads that suggest this is a known issue with this version of Acrobat but I would like conformation from Adobe that this is a known issue and whether it is fixed in a newer version?
    Adobe Acrobat version 10.1.13
    SharePoint 2010

    Hi quodd,,
    We are sorry for the issue being faced by you. I need some information from you so that I take further steps:
    1. Which Adobe product are you using Acrobat or Adobe reader- what is the complete version?
    2. How are you opening and saving the PDF, the exact workflow?
         Are you doing it from within Adobe Reader/Acrobat application or opening it from browser, doing changes and saving it using browser itself.
    3. Can you try to save a PDF to library with Custom template and managed metadata columns using browser directly.
    4. Please verify that columns name do not contain spaces or some other special characters.
       Can you try to save PDF to library with Custom template and just a single managed metadata column  with a simple name
    Thanks,
    Nikhil Gupta

  • Mac mini Server 10.6  unable to search for files on the server from desktop.

    I'm running Mac mini Server 10.6 with 15 various Apple Mac desktops 10.4 / 10.6. The problem i'm having is that i'm unable to search for files on the server from any of the desktops. I have fixed permissions and rebooted. I can perfomr a search though command - F and spotlight from the server.
    Anyone have any ideas?

    I have a Mac mini server with Mac osx 10.6.8 installed --- I have a website {UNDER CONSTRUCTION} installed on it with a REGISTERED DOMAIN NAME belizeansworldwide.com -->[DNS service w/GoDaddy]  & DSL INTERNET service  w/VERIZON --- {My server is the ONLY DEVICE CONNECTED to my VERIZON DSL router/modem}
    When I enter my DOMAIN NAME or WAN IP # in my browser(s)--> Chrome OR Safari -- i get my Verizon modem
    set-up page-->{this incl the WAN IP# as I expected}----{NORMALLY I WOULD ACCESS MY Actiontec
    modem/router via 192.168.1.1} --- While in that webpage there's an option "shared files/folders"   & clicking on that option DISPLAYS MY WEBSITE --->  {"PORT FORWARDING DID NOT RESOLVE THAT"}
    My next attempt @ a solution was through my Server's SystemPreference>Sharing>Internet Sharing
    & this the Original Object of my post ===>  "MY SHARING PANEL DOES NOT INCLUDE THE OPTION
    FOR   'Internet Sharing' among the others like CD DVD, Remote Login,Remote Management, Bluetooth Sharing, etc.etc ---- Hope this additional info will help to clarify  &/or explain my problem
    Thanks, & best regards to you & yours

  • How to Invoke tasks created in FrameMaker Publishing Server from the Windows command line

    Hi All ,
    i would like to know how can we Invoke tasks and schedules created in FrameMaker Publishing Server from the Windows command line.
    we used publishing server mainly to convert Frame maker files into PDF and that should be do progarmatically without manual intervention on Demand.
    so could you please let us know how can i invoke rthe task creted to convert FM file to PDF in FrameMaker Publishing Server from the Windows command line.
    please let me know the command to execute .
    thank you and waiting for valuable response.
    best regards
    Ramesh babu

    Please see http://blogs.adobe.com/techcomm/2011/03/adobe-framemaker-server-10-and-its-command-line-ca pability.html for the same.
    Harish Dhawan

  • How do shutdown the weblogic server from the command line prompt using web logic 8.1

    I%u2019m currently using weblogic 6.1, but I will upgrade to weblogic 8.1. In weblogic 6.1, the following statements will shutdown the weblogic instance from the command line:
    java weblogic.Admin -url t3://hostname:port -username system -password abc SHUTDOWN
    How do I shutdown the weblogic server from the command line prompt using web logic 8.1.
    Any help will be greatly appreciated.
    Maria

    Maria <[email protected]> wrote:
    How do I shutdown the weblogic server from the
    command line prompt using weblogic 8.1?Greetings Maria! Use this document, located here:
    http://edocs.bea.com/wls/docs81/admin_ref/cli.html#1131733
    Hope this helps...
    Brian J. Mitchell
    Systems Administrator, TRX
    email: [email protected]
    office: +1 404 327 7238
    mobile: +1 678 283 6530

Maybe you are looking for

  • How do i unlink a phone number from my mac?

    I share an apple id with my family and i want to one phone number so that i can link a different one. Any help wold be appreciated. Thanks!!!

  • Loading project stuck on 100%

    Hi all This is so frustrating yet Im not sure if this is a fault or default behaviour. I will load a project and then have to wait and wait. and wait Eventually the project will load, but first it will prompt with "Where is the file 0000026.MTS" . I

  • Verification Failed. The certificate for this server is invalid

    I am trying to backup my iPad to iCloud.  I get: Verification Failed.  The certificate for this server is invalid. You might be connecting to a server that is pretending to be "setup.icloud.com" which could put your confidential information at risk.

  • Accessing Time Capsule disk from Windows 7

    I have a Time Capsule 2TB which serves several Macs and a PC running Windows 7. I was able to access the disk from Windows 7 to share files. My PC suddenly stopped seeing the disk - although the Windows 7 machine can still access the web through the

  • Regardin function modul

    what is the function moudle is used to get the long text in the report for purchase orders and sales orders say clearly