Displaying text in local web browser

Hi,
Been looking at a web forwarding program that accepts a GET request from a browser and goes off and gets the page from the remote server and then needs to feed that page back to the browser. I've got as far as getting the page back from the remote site but was wondering how to post it back on the web page.
import java.io.*;
import java.net.*;
public class WebFwd{
    private int fwdPort;
    private ServerSocket listener = null;
    private Socket socket;
    private String remoteURL;
    private int browserPort;
     public WebFwd(int i){ //Constructor to create an instance
          fwdPort = i;
          listenSocket();
     public void listenSocket(){
          try{
                listener = new ServerSocket(fwdPort);
                System.out.println("Server socket up and running on port " + fwdPort);
           catch (IOException e){
                System.out.println("Could not listen on port "+ fwdPort + ".");
                System.exit(-1);
          while(true){
               try{
                    //listener.accept returns a client connection.
                    socket = listener.accept();
                    browserPort = socket.getPort();
                    DataInputStream dis = new DataInputStream(socket.getInputStream());
                    byte [] data = new byte[1024];
                    dis.read(data, 0, data.length); //read in the data from the browser to the socket
                    String byteStr = new String(data); //convert the byte array to a string
                    System.out.println(byteStr.trim()); //print out the contents of the GET request trimming the whitespace
                    parseString(byteStr); //cut up the GET request to obtain destination
               catch (IOException e){
                    System.out.println("Accept failed: "+ fwdPort + ".");
                    System.exit(-1);
      * Get the remote location of web page
     private void parseString(String get){
          String [] getArr = get.split("/");
          String [] getArr2 = getArr[1].split(" ");
          remoteURL = "http://" + getArr2[0];
          forwardRequest();
      * Forwards request to the remote location
     private void forwardRequest(){
          try{
               URL u = new URL(remoteURL); //create a new URL to remote location
               InputStream is = u.openStream(); //open a stream on that url
               //create new dis to read the data from the remote server
               DataInputStream di = new DataInputStream(new BufferedInputStream(is));
               String s;
               //while there is stil something to read, read it
               while ((s = di.readLine()) != null){
                      System.out.println(s); //prints contents of remote URL here
                      //Need to find way of redirecting it to the browser
                       // Send data
                  URL url = new URL("http://localhost:" + browserPort);
                  URLConnection conn = url.openConnection();
                  conn.setDoOutput(true);
                  OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
                  wr.write(s);
                  wr.flush();
        catch(MalformedURLException mue){
             mue.printStackTrace();
        catch(IOException ioe){
             ioe.printStackTrace();
     public static void main (String args[]){
          WebFwd wbfwd = new WebFwd(30280);
}I keep getting a connection refused exception in the while loop of forwardRequest(). There is obviously a "correct" way to do it but before I start mucking around with my firewall I thought I would check that I'm in the right ballpark.
Kind regards,
Chris

Uh, when your proxy (as a web forwarding program is called) receives a GET request, it should reply with the contents of the URL requested.
So
1) read request from socket
2) obtain URL stream
3) write stream contents back to socket
Catfish?

Similar Messages

  • Display HTML Tags on web browser

    My problem is display Html code in web browser.
    i try TextArea.htmlText, Label.htmlText... but they don't
    work...
    i'm searching in google.com and i know Html Component can do
    that, but it not well because i don't have money for that.
    Some body help me for my problem.
    Thanks so much. !
    nice day every body.

    The htmlText property should work however only a few basic
    html tags are supported as far as I know.

  • Display the reports in web browser?

    I need advise.. Here is my requirements.
    we are using Oracle9i database. We have data warehouse Schema. We wanted to display some of the reports in the browser. What are the possible solutions to display the reports in web browser with out using any reporting tools(cognos, business objects etc).
    Thanks

    Well your requirement is a little bit odd, displaying data in database without using tools or application. What's form of these reports you are talking about? Are they just bunch of queries?
    If you don't want to use heavy duty software like cognos or business objects, then consider use Oracle Application Express APEX
    http://www.oracle.com/technology/products/database/application_express/index.html
    by the way cognos and business objects are OLAP tools, does that mean your reports are OLAP report?

  • Display PDF document in web browser

    Hi,
    I have a smartform which is being triggered from Web UI. I got the data and converted it to PDF format.
    I need to display this PDF data in a web browser Pop up.
    Please let me know how can I do that.
    Thanks
    Abhishek

    Abhishek,
    If you are using the business transaction types, you can setup a default "print" action which then when you click on the "print preview" in the webUI you will get an PDF output view of the print output.
    If that doesn't work, then look at the business partner factsheet code delivered by SAP which will show how to display a PDF.
    Look at component/view BP_HEAD/BPHEADOverview
    Class CL_BP_HEAD_BPHEADOVERVIEW_IMPL
    method IF_BSP_WD_TOOLBARR_CALLBACK~GET_BUTTONS
    and this section of code
          IF lr_partner IS BOUND AND lv_enabled = abap_true.
            lr_partner->get_property_as_value( EXPORTING iv_attr_name = 'BP_GUID'"#EC NOTEXT
                                               IMPORTING ev_result    = lv_partner_guid ).
            IF lv_partner_guid IS NOT INITIAL.
    *       ICF handler class prepares java script
              CALL METHOD cl_crm_afs_print=>get_url
                EXPORTING
                  iv_object   = lv_object
                  iv_key      = lv_partner_guid
                  iv_role     = lv_business_role
                  iv_language = sy-langu
                  iv_form     = ' '     "read from customizing
                  iv_format   = lv_format
                IMPORTING
                  ev_url      = lv_url.
              IF lv_url IS INITIAL.
                lv_enabled = abap_false.
              ELSE.
                lr_cuco_head ?= get_custom_controller( 'BP_HEAD/Lifecycle' )."#EC NOTEXT
                IF lr_cuco_head IS BOUND.
    *              CONCATENATE '"' lv_url '"' INTO lr_cuco_head->gv_preview_url.
                  lr_cuco_head->gv_preview_url = lv_url.
                ENDIF.
              ENDIF.
            ENDIF.
            ls_button-text  = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_BP/BP_PDF' )."#EC NOTEXT
            ls_button-tooltip  = cl_wd_utilities=>get_otr_text_by_alias( 'CRM_UIU_BP/BP_FS_PREVIEW' )."#EC NOTEXT
    *        ls_button-on_click = 'PREVIEW'.
            ls_button-on_client_click = 'OpenPopUp()'.          "#EC NOTEXT
            ls_button-page_id  = me->component_id.
            ls_button-enabled = lv_enabled.
            ls_button-icon_src = '/sap/bc/bsp/sap/crm_ppm/w_pdf__s.gif' ."#EC NOTEXT
            APPEND ls_button TO rt_buttons.
            CLEAR ls_button.
          ENDIF.
        ENDIF.
      ENDIF.
    Good luck,
    Stephen

  • Fast display of ResultSet to web browser

    I am working on refactoring my companies search engine, and a critical component of the search is that the results be displayed very quickly. We have done enourmous work on making the queries fast (under 1 second), but the bottleneck always seems to be how we process the results into HTML and send them to the users web browser.
    Running Tomcat, we currently use a JSP page to pass the search parameters to a Java class that queries the database and generates HTML based on the ResultSet object. The method we use to generate the HTML is very low tech, we simply generate a String that contains HTML along with the data from the ResultSet and print the String out to the users web browser via the PrintWriter object obtained from the session.
    I would like to solicit ideas as to how this process can be improved. What's the absolute fastest way to get ResultSet data transformed into HTML and displayed in the users browser? I'm exploring maybe using the XML, but I haven't found much information about the speed of that technology. One caveat is that the data has to be processed before display,in the sense that if certain flags are set in a row of the ResultSet, that row data should be displayed accordingly.
    We currently do something like this many times:
    String html = "<table>";
    if(resultSet.getInt(3) == SOME_FLAG) {
        html += "<tr><td><font color='red'>resultSet.getString(6)</font></td></tr>";
    html += "</table>";It would be nice if the suggestions would fit into our current Oracle/Solaris/Tomcat/JSP/Servlet architecture, but not a requirement.
    Thank you very much!
    P.S. Sorry if this isn't the right category for this. I labored long and hard deciding which category to post this question under, and this one seemed to be the best fit.

    Check out the FormattedDataSet. It does things similar to what your code does, but is much more flexible AND monitored for performance in with JAMon. Out of the box it can create html tables, list boxes, drop downs, multi selects and html. As a developer you can generate dynamic text to appear any way you dream up.
    Here is some sample code
    FormattedDataSet fds=FormattedDataSet.createInstance();
    // same query vary the formatting. note other types of tabular data are also accepted
    String html=fds.getFormattedDataSet("select * from table", "htmlTable");
    String xml=fds.getFormattedDataSet("select * from table", "xml");
    String csv=fds.getFormattedDataSet("select * from table", "csv");Check out a live demo at http://www.fdsapi.com. Within the next week I hope to have a live demo that allows you to type in queries. You can already download a demo war that has this capability.
    steve - http://www.fdsapi.com - the easiest way to generate dynamic content.

  • N95 - no text appears in web browser

    When I connect to the Internet through my N95 WiFi connection, I get the images but not the text on the web pages. Even when I write something (like user name and password) I cannot see what I am writing.
    Will be thankful if someone would give me a solution. Thanks.
    Solved!
    Go to Solution.

    i have contacted the developer of Ramadan applications.
    The problem is in fonts used in Quran and it was fixed.
    Please see the solution below:
    Dear Customer,
    Thank you for contacting ASGATech support,
    After investigation to the browser problem We found that Quran font conflicts with this browser font, so we updated the Quran version and it's available at:
    http://mea.nokia.com/english/ramadan
    1-Restart your mobile.
    2-Uninstall the old version.
    3-install the new version.
    Thanks and best regards,
    ASGATech support team/ Noha

  • Box with rounded corners displays as rectangle in Web Browser

    I am using the box control (IBoxObject) in my Crystal Reports with rounded corners. However the box displays as a rectangle with square corners when viewed in a web browser. I have tried this in IE 7.0.5730.13, Firefox 3.0.3 and Chrome 0.2.149.30 all give the same problem.
    The interesting thing is that the boxes display correctly at design time and when exported to PDF, but they wonu2019t display correctly in IE/Firefox/Chrome. Here are the specific settings for the box:
                    CornerEllipseHieght = 375
                    CornerEllipseWidth = 375
                    Crystal Reports Version 10.5.3700.0
    I have also attached an image to try and clarify the problem.
    [Picture showing Box at design time, in a Web browser and when exported to PDF|http://i38.tinypic.com/10p6k1v.jpg]
    Thanks in advance for any help with this issue.
    -John

    Thank you Ted, this was my take on the problem but it is good to have a confirmation.
    There are CSS (HTML) solutions for creating boxes with rounded corners, such as [SpiffyBox|http://www.spiffybox.com/] and [CSS Rounded Box Generator|http://www.neuroticweb.com/recursos/css-rounded-box/index.php?idioma=en] and many more that can be found using [Google|http://www.google.com/search?hl=en&q=cssboxeswithroundedcorners&btnG=Google+Search&meta=].
    Do you know of any plans to support rounded corners in the future?
    Thanks for your help!
    John

  • 39L4333DG - cannot display Flash content in web browser

    Hello,
    When I try to access Flash sites the web browser shows 'Missing plugin' in the frame where flash player should display the content.
    Am I omitting anything?
    I have installed the latest firmware: 7.1.90.34.01.1.
    For a 2013 TV it is annoying not to have a full featured web browser on a SMART TV.
    Is there any chance to have a full web browser in the next firmware version?
    Thank you.

    When I had similar problems the response from Toshiba was that the browser is only intended for limited use. My problem was not being able to access any site which required a password. Not rocket science you would think!

  • SRM 4.0-- Blank Page displayed without Errors  through Web Browser

    Hi All,
    Can any one help me in the following ....
    We are trying to give access through the Web Browser instead of Sap GUI.
    we have started all the services through SICF.
    when we tried test service through WEB GUI it is showing  a blank page.
    It is not giving any errors on the page.
    there is no problem in the URL..
    Can any one help me by giving option of errors and where to check.....
    Bye
    Suresh

    Hi
    Read this ->
    <u>The entries in table TWPURLSVR should be as follows:
    e.g.</u>
    LOGSYS : MRDCLNT100
    WEB SERVER : SAPDEV14.XEROX.COM:8001
    WEB PROTCL:HTTP
    WIN SERVER:SAPDEV14.XEROX.COM:8001
    WIN PROTCL:HTTP
    BSP SERVER:SAPDEV14.XEROX.COM:8001
    BSP PROTCL:HTTP
    <u>Also, refer to OSS Note 790727 describes the details for publishing all the services</u>
    Refer
    <b>why can I not find Service BBPGLOBAL in TA SICF?
    for details.
    Regards
    - Atul

  • How to display applet in the web browser?

    Hi Just want to ask help. Im making an application and i want to display applet in JSP. The problem is when i run my application there's no display in the browser. I already try to put the JSP and the Java Class with the same folder but still not working. Kindly help me with this one..
    Code:
    <jsp:plugin code="appletImage.class" codebase="applet" type="applet">
    </jsp:plugin>
    With this one i put my class in a package

    I think (correct me if im wrong) that that is the old way to do it i.e. it is now deprecated and that the recommended way now is to use the object tag
    Old deprecated way example
    <APPLET code="Bubbles.class" width="500" height="500">
    Java applet that draws animated bubbles.
    </APPLET>New recommended way example
    <OBJECT codetype="application/java"
            classid="java:Bubbles.class"
            width="500" height="500">
    Java applet that draws animated bubbles.
    </OBJECT>

  • Displaying .ICO images in web browser

    I have a need to display .ICO icon images within the browser. I'm finding that in MSIE they don't always work and in Firefox they display but they are very blurred. I'm wondering if anybody is aware of anything built into CF that might fix this problem? Possibly a flash component?
    CF never ceases to amaze me, it always has a tag or component for every issue, but this one might be a problem!
    Thanks
    Mark

    ACS LLC wrote:
     CF never ceases to amaze me, it always has a tag or component for every issue, but this one might be a problem!  
    Thanks
    Mark
    Yeah, since CF is a server technology and "I have a need to display .ICO icon images within the browser." kind of indicates that you are dealing with a client issue.
    I am fairly confidant that the <cfimage...> tag is not going to do anything with the .ico format.  At least I have never heard about it doing so.  It is possible that there is java code out there that could do something with the ico format that will make it work better.  If so, it should be pretty easy to inovke the java from within your CFML.

  • Which (Text|Terminal)-based Web Browser to use?

    So after seeing phrakture's post about w3m + w3mimgdisplay? or something like that, I was wondering what terminal browsers people preferred and why.

    I used elinks for a while because it renders html decently.  Then I realized "it's a text mode browser, I want it to render how it looks best in text", and that seems to be w3m.
    What I like most about w3m is the sane navigation.  elinks key navigation used to piss me off.  Sure, you could change it, but that's alot to change.
    w3m seems to have more "sane defaults" - it's the same reason I like weechat over irssi.
    That said, the w3mimgdisplay thing just furthers the "OMG" factor of w3m.
    It *does* work within screen too, but not over ssh (yet?).  The only problem is that w3m images are positioned with absolute values, and it can't interpret where screen splits are at, so renders on top of other crap.

  • Display PDF in Web Browser Setting

    Good Morning,
    We recently encountered some issues with Adobe 9.0.0 on Citrix servers. We updated to Version 9.3.4, since we had not fully tested Reader X yet.
    The issue is that we have an application that calls to Adobe and opens PDF files within the application.  When I log on to the citrix server locally, the setting Display in PDF Browser is selected.  My account is an admin of our domain. When I log in to the server with a standard account, the setting is not selected.
    I found the bBrowsing Integration key in HKCU\Software\Adobe\Acrobate Reader\9.0\Originals and when I am logged in with admin account it is set to 1, when I login with the non-admin account it is set to 0.
    The same key also appears in HKEY_Users\.Default\Software\Adobe\Acrobat Reader\9.0\Originals.  My question is this, can I set this globally on my Citrix servers so that the Display PDF is Browser is selected. when users login to Citrix Presentation Server, launch the applications that call to Adobe, that the pdf open in a web browsers of the applications. Currently, if you hit the link the PDF file will open in its own window.
    Sorry if this is a bit wordy, but I figure it is best to give too much info as opposed to not enough.
    Thank You
    Brian Dougherty

    Yes the pdf is opening in adobe. But I don't want to open a new adobe browser to open.
    I want to display in the current web browser where my application is running.
    eg. if u are embedding pdf file like this.
    <EMBED src="temp1.pdf" width ="750" height="550"></EMBED>
    It won't open the new window. It displays the result in the current window.
    I have my pdf content in byte array. To wirte the above code i need a file. I even writes the byte array to a temporary pdf file. But I can't able to import that file dynamically to the WSAD workspace.
    Is there any other way to embed the (byte array)pdf file in the current window.
    Please advice me.
    Thanks in advance.

  • Apex Listener started successfully however nothing show on the web browser

    Apex Listener started successfully, when try to visit APEX (http://localhost:8080), nothing showing on the local web browser. See following output message during the startup of APEX Listener. Thank for your help.
    Kevin
    D:\app\administrator\apex_listener.2.0.0.354.17.05>java -jar apex.war
    Feb 16, 2013 2:17:23 PM oracle.dbtools.standalone.Standalone execute
    INFO: NOTE:
    Standalone mode is designed for use in development and test environments. It is not supported for use in production environments.
    Feb 16, 2013 2:17:23 PM oracle.dbtools.standalone.Standalone execute
    INFO: Starting standalone Web Container in: D:\app\administrator\apex_listener.2.0.0.354.17.05\apex
    Feb 16, 2013 2:17:23 PM oracle.dbtools.standalone.Deployer deploy
    INFO: Will deploy application path = D:\app\administrator\apex_listener.2.0.0.354.17.05\apex\apex\WEB-INF\web.xml
    Feb 16, 2013 2:17:24 PM oracle.dbtools.standalone.Deployer deploy
    INFO: Deployed application path = D:\app\administrator\apex_listener.2.0.0.354.17.05\apex\apex\WEB-INF\web.xml
    Feb 16, 2013 2:17:24 PM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
    INFO: Using configuration folder: D:\app\administrator\apex_listener.2.0.0.354.17.05\apex
    Configuration properties for: apex
    cache.caching=false
    cache.directory=/tmp/apex/cache
    cache.duration=days
    cache.expiration=7
    cache.maxEntries=500
    cache.monitorInterval=60
    cache.procedureNameList=
    cache.type=lru
    db.hostname=dpuwomd-cluster
    db.password=******
    db.port=1521
    db.servicename=dpuwomor.clevelandwpc.com
    debug.debugger=true
    debug.printDebugToScreen=false
    error.keepErrorMessages=true
    error.maxEntries=50
    jdbc.DriverType=thin
    jdbc.InactivityTimeout=1800
    jdbc.InitialLimit=3
    jdbc.MaxConnectionReuseCount=1000
    jdbc.MaxLimit=10
    jdbc.MaxStatementsLimit=10
    jdbc.MinLimit=1
    jdbc.statementTimeout=900
    log.logging=false
    log.maxEntries=50
    misc.compress=
    misc.defaultPage=apex
    security.disableDefaultExclusionList=false
    security.maxEntries=2000
    db.username=APEX_PUBLIC_USER
    Using JDBC driver: Oracle JDBC driver version: 11.2.0.3.0
    Feb 16, 2013 2:17:26 PM oracle.dbtools.rt.web.SCListener contextInitialized
    INFO: Oracle Application Express Listener initialized
    Application Express Listener version : 2.0.0.354.17.06
    Application Express Listener server info: Grizzly/1.9.49
    Feb 16, 2013 2:17:26 PM com.sun.grizzly.Controller logVersion
    INFO: GRIZZLY0001: Starting Grizzly Framework 1.9.49 - 2/16/13 2:17 PM
    Feb 16, 2013 2:17:26 PM oracle.dbtools.standalone.Standalone execute
    INFO: http://localhost:8080/apex started.

    Hi Kevin,
    this looks like a common issue: You've probably not configured the static contents for APEX ("images") properly. Please make sure you've set the parameter to point to a path that contains the contents of the "images" directory of the APEX installation package that fits to the APEX version of the instance your APEX Listener is supposed to host.
    -Udo

  • Signing a pdf in web browser

    I am setting up a web application where a person can open a PDF in their browser and sign a signature field in a PDF form.  Once they sign it they can click a submit button in the PDF form and it submits the form data via HTTP (not FDF or XFDF).
    They can sign it, but when the form is submitted back to the web server the signature data is not part of the form data.
    Is there any way to get the signature data in the form data that the PDF is sending?
    Thanks!

    Yes the pdf is opening in adobe. But I don't want to open a new adobe browser to open.
    I want to display in the current web browser where my application is running.
    eg. if u are embedding pdf file like this.
    <EMBED src="temp1.pdf" width ="750" height="550"></EMBED>
    It won't open the new window. It displays the result in the current window.
    I have my pdf content in byte array. To wirte the above code i need a file. I even writes the byte array to a temporary pdf file. But I can't able to import that file dynamically to the WSAD workspace.
    Is there any other way to embed the (byte array)pdf file in the current window.
    Please advice me.
    Thanks in advance.

Maybe you are looking for

  • How many users in UME

    Hi, Does anyone have any idea on how many users can be stored in the UME engine without affacting performance? We have a current senario with about 200 portal useres, but are going to use the portal with more users in the future. The users are stored

  • CORBA COMM FAILURE AND ORB

    We are currently experiencing numerious and periodic CORBA COMM FAILUREs in prd. We are utilizing JDK 1.3 / CORBA and trying to submit to a C++ server object. When the web server starts up, it initializes the ORB using the ior and orb.init(). When th

  • I have two time capsules, one for work and one for home, how do I set up the work time capsule to only back up my work files?

    I have two time capsules, one for work and one for home, how do I set up the work time capsule to only back up my work files?  Also, how do I add co-workers to my work time capsule and wife to my home time capsule?  Thank you!

  • Pal vs. Ntsc with mpeg 1 format

    This may be a long question.... I have several small videos that i shot on a point and shoot, Sony dsc w80, that i want to edit in final cut. i am assuming that they are standard ntsc for they are recorded at 30fps, 640 x 480. I will also be using ot

  • RENDER and AVI and CODEC issues

    I've ripped a DVD clip from Handbrake-- AVI file and Codec is AVC/H.264 video/MPS audio (that's how it is) and it will go into FCP ok and to the timeline. It needs rendered and so begins the problem. It says, there's a "render error and not enough di