How to get a connection via a proxy?

Hello all,
I'm writng an application that sends a request to the google search engine and then downloads the contents of the web page returned. Connecting from home via a dial up causes no problems but when i try the same code from college (which uses a proxy) i get an IOException. I think this is what is causing the problem. Another developer posted a message with a similar problem to myself and i used the code he was given as a possible solution but it hasn't solved the problem. I posted the code i'm using below. any suggestions would be welcome because i'm clueless as to what to do next.
import java.net.*;
import java.io.*;
import java.util.*;
public class GoogleConnector {
String hostname = "www.google.com";
int port = 80;
String s1, s2 = new String();
Set hs = new HashSet();
Properties systemProperties = System.getProperties();
// here is the method to get the URLs
public Set getList(String arg1) {
try {
systemProperties.put("proxySet","true");
systemProperties.put("proxyHost","192.168.5.251");
systemProperties.put("proxyPort","3129");
systemProperties.put("socksProxyPort","3129");
systemProperties.put("socksProxyHost","192.168.5.251");
System.setProperties(systemProperties);
Socket s = new Socket(hostname,port);
InputStream sin = s.getInputStream();
BufferedReader fromServer = new BufferedReader(new InputStreamReader(sin));
OutputStream sout = s.getOutputStream();
PrintWriter toServer = new PrintWriter(new OutputStreamWriter(sout));
Send request as specified in arg1 to the server
and write whole page as a string broken up by newline character
toServer.print("GET " + arg1 + " HTTP/1.1\n");
toServer.print("Host: " + hostname + "\n\n");
toServer.flush();
for (s1 = null; (s1 = fromServer.readLine()) != null; ) {
s2 += s1 + "\n";
// close all connections
toServer.close();
fromServer.close();
s.close();
I do some other processing here but it's not relevant to the connection problem.
catch (UnknownHostException ue) {
System.out.println("UnknownHostException");
catch (IOException ie) {
System.out.println("GoogleConnector: IOException");
return hs; //can ignore this return statement
} // end getList
} // end GoogleConnector

Here's a working code sample to connect using a proxy server:
http://www.esus.com/docs/GetQuestionPage.jsp?uid=666
and don't forget, you can use the google web api's:
http://www.esus.com/docs/GetQuestionPage.jsp?uid=1570
Cheers

Similar Messages

  • How to get Messageid in Inbound ABAP Proxy ?

    Hi,
    Please advise how to get messageid in Inbound ABAP Proxy, so far i could not find anythings most of the forum discuss about "How to get messageid for Outbound Proxy).
    Thank You and Best Regards
    FL

    Hi Fernad,
    By using below code you can take message id.
    java.util.Map map = container.getTransformationParameters();
    return ((String) map.get(StreamTransformationConstants.MESSAGE_ID));
    Create one simple UDF by using above code and map this to one field (you may create one dummy field for this). Then at runtime the mapped field contains the message id.
    Regards,
    Venkata Ramesh

  • How to get database connection in applet

    Hi,
    I am trying to prepare database connection in applet. After preparing connection with database it'll read same values from table.
    At the time of development it works fine. I have used esclipse IDE for coding and testing.
    But when I try to call that applet from browser. It is giving ClassNotFound exception.
    Does anybody know How to get database connection in applet ?
    Please help me if anybody know solution for this.
    Thanks,
    Rajesh

    As per my knowledge is conserned
    1 u can get the database connection in a jsp page and u send the result set as param to the applet and u can use retrieved values as if they were of the same applet if u r interested i can send the db connetion coding for jsp my id [email protected]

  • Hey there! well i from india and i m facing problem connecting my debit card to the itune store ,as the very option is not there, can someone guide me how to get it connected , i have a mastercard debit card with me .please help me

    hey there! well i from india and i m facing problem connecting my debit card to the itune store ,as the very option is not there, can someone guide me how to get it connected , i have a mastercard debit card with me .please help me

    if you are signed in to iTunes with your AppleID, click on the AppleID > view account > payment information > enter in your information

  • I have just purchased Apple TV today everything works fine on my TV but I don't no how to get it connected to my ipad or I phone

    I have just purchased Apple TV today everything works fine on my TV but I don't no how to get it connected to my ipad or I phone

    Welcome to the Apple Community.
    Assuming both devices are on the same network and that AirPlay is not turned off on the Apple TV, then simply tap on the screen when you are watching content you wish to stream to your Apple TV, then tap the airplay icon that appears in the control bar, choose the Apple TV from the menu that appears.
    When displaying the content you wish to mirror on the iPad 2 (or better), iPad Mini, iPhone 4S (or better), double tap the home button (quickly) and swipe the bottom row of apps to the right to reveal the playback controls, tap the AirPlay icon and select your Apple TV from the list of available devices.

  • How to get internet connection from Airport Express to a PC?

    I recently bought an Airport Express to get internet connection from my new MAC COMPUTER TO ANOTHER PC which is located in another room. For unknown reason, I could not get the other PC to work. Any idea how to fix it so that I can get internet connection for my PC? Many thanks for your expert assistance.

    Currently, the Airport Express (not the Airport Express Extreme router) is acting as a base station via Ethernet to a cable modem.
    I guess that it would be correct to assume that your new Mac can connect wirelessly to the AirPort Express base station, and access the Internet that way.
    I am not sure if my 41/2 year old HP(Hewlect Packard) PC - (with AMD Athlon 64 3400 processor) which I am unable to get internet connection now is Wi-Fi capable.
    You said "Prior to using the new Airport Express,I was using the Linksys wireless G router and have a wireless adapter sitting on top of my PC.". The wireless adapter would be Wi-Fi certified (they normally are). Is it a USB adapter? Please post back with the exact model.
    Question: do I still need to use the adapter or not? Or the new Airport Express is enough to send internet signal to the PC?
    A Wi-Fi adapter would act as a wireless network card for a PC, and should communicate wirelessly with an AirPort Express base station without a problem (providing that the chosen security/encryption is supported on both sides). Since the wireless adapter apparently was OK (with the Linksys router), you should be able to continue using it. Any other (built-in) wireless capability ought to be externally visible at the PC as a PCI card with an antenna.
    Does the (Windows?) PC operating system detect any wireless networks? Is your AirPort Express on this list (even if you cannot connect or access the Internet)?
    Jan

  • How to get a connection which does not participate in the main usertransaction

              Hi All I am on WLS 6.1 sp2 on win2k. I have a requirement which is like this: I
              use connection pools/txdatasources/JTA in my application. Now when a JTA transaction
              (UserTransaction) is active - I want to take a connection from the pool and do
              some operation and commit it independently of the UserTransction commit/rollback.
              Its pretty much like this - 3 components A , B, C (none of them are EJBs) are
              involved in a UserTransactions and all of them access database via a TxDataSource
              (say TD) which points to a connectionpool (say CP). Now I want B to get a connection
              handle which is not participating in the main transaction - so that the operation
              that B does is independent of what happens to the main transaction. Now I know
              I can use TransactionManager api to suspend a UserTransaction and then let B take
              a connection from the pool and commit it and then resume the transaction. But
              is there any easier way out of it? Like if B uses a DataSource instead of a TXDataSource
              - will that give B a connection which is not part of the main transaction? if
              not then whats the difference between DataSource and TXDataSource? Any help is
              appreciated.
              thanks
              Anamitra
              

    I would recommend that you mark the method as NotSupported or
              RequiresNew rather than using DataSource or suspending/resuming
              transactions on your own.
              If anything, it will be much clearer to the next person who maintains
              your code.
              -- Rob
              Anamitra wrote:
              > Hi All I am on WLS 6.1 sp2 on win2k. I have a requirement which is like this: I
              > use connection pools/txdatasources/JTA in my application. Now when a JTA transaction
              > (UserTransaction) is active - I want to take a connection from the pool and do
              > some operation and commit it independently of the UserTransction commit/rollback.
              >
              >
              >
              > Its pretty much like this - 3 components A , B, C (none of them are EJBs) are
              > involved in a UserTransactions and all of them access database via a TxDataSource
              > (say TD) which points to a connectionpool (say CP). Now I want B to get a connection
              > handle which is not participating in the main transaction - so that the operation
              > that B does is independent of what happens to the main transaction. Now I know
              > I can use TransactionManager api to suspend a UserTransaction and then let B take
              > a connection from the pool and commit it and then resume the transaction. But
              > is there any easier way out of it? Like if B uses a DataSource instead of a TXDataSource
              > - will that give B a connection which is not part of the main transaction? if
              > not then whats the difference between DataSource and TXDataSource? Any help is
              > appreciated.
              > thanks
              > Anamitra
              

  • How to get current connection from ejb container

    We have to execute sql statement directly to the database and will use for this issue to connection establish between the ejb container and the database.
    How to get the corresponding object ?

    thanks

  • How to get (database) connections for building an extension in 11g?

    Hi,
    I have built an extension for jdeveloer/sqldeveloper and I used the ConnectionManager Class to start my dockable.
    Having migrated from Jdev10g to 11g it looks like that the ConnectionManager class was removed, at least I'm
    not able to locate it anymore.
    I've provided the source code below, to show how I used to work with the class.
    String connectionNames[] = ConnectionManager.getInstance().getConnectionNames();
    DatabaseConnections.getInstance();
    ... Loop ...
    if (i >= connectionNames.length)
    break;
    String name = connectionNames;
    if (name.equals(dockableId))
    ... Start dockable...
    What is the supported way to work with connections in 11g?
    Best regards,
    Ingo

    Hi,
    thanks for the quick response. Seems that my extension project in Jdev 10g was messed up by putting the new sqldevloper.jar in the class path. I've migrated to Jdev11g and the missing class is found.
    Where I'm lost right now is the way to get a connection from the pool. Most of the classes that I used for that (oracle.jdeveloper.cm.dt.ConnectionNode, oracle.jdeveloper.cm.dt.DatabaseConnectionNode;)
    are not longer existing and it looks like there is a new way to achieve this in Jdev11g.
    Is there a documentation available somewhere, where the "new" strategy is explained?
    Best reagards,
    Ingo

  • How to get a connection from ejb container

    How is it possible to get the connection used by the ejb container to execute some specific sql statement without establishing a new jdbc connection.

    repost ... please help

  • AnyConnect on Apple iOS - VPN-Connect via HTTP-Proxy

    Hi,
    is it possible, that the AnyConnect-Client for Apple iOS (i.e. iPAD) automatically uses the configured HTTP-Proxy in the WLAN properties for the establishment of the VPN-Connection (via SSL/TLS)?
    I've tested it, but it does not work. In the documentation is stated, that VPN establishment via HTTP-Proxy works only in Windows (AnyConnect uses the IE Proxy settings to connect to the ASA for VPN establishment).
    Thanks

    As per w2k3 sniffer trace, 2851 requesting with user=vpnfamily and encrypted password. The password "Password1" which is VPN group's key sending to IAS?
    ->I have "vpnfamily" with password "Password1" but no luck
    Event log shows "Fully-Qualified-User-Name = INFRA\vpnfamily". INFRA is AD NetBIOS name. 2851 router's domain name is "family.com"
    ->Is this something wrong?

  • How to get the connection name of a Dataprovider

    Hi,
         I have a report with stored procedure dataprovider.Now I need to write a VBA script to get the connection name of this dataprovider.Is it possible to get the connection name of dataprovider?
    Thanks
    Rakul.

    What product are you using? Are you using Crystal Reports? Business Objects Enterprise? SAP product(s)? You sure you are asking in the correct forum?
    Ludek

  • How to get datbase connection in Struts

    I m not getting database connection while entering the data into database. can you provide any help for that please its very urgent

    [Click here|http://catb.org/~esr/faqs/smart-questions.html#urgent]
    db

  • How to get the connection with PM in sequencefactory?

    In SequenceFactory interface the following method
    public long getNext(Class cls, Connector connector)
    is to get the next sequence number, and one can use the connector to get a
    new connection, but at most time, when the kodo call this method, there
    must a PM exist, so if I want to use the connection with the exist PM, not
    a new connection, how can I get to it!

    Maguohai-
    You can't do this with datastore identity, but you could use application
    identity, and have the id assigned wherever use want, using SQL executed
    via a Connection obtained in the way described at:
    http://docs.solarmetric.com/manual.html#feature_sql_connection_access
    In article <bc0n3c$n9l$[email protected]>, maguohai wrote:
    Yes, you are right, but if generate the sequence need not transaction(for
    example using DBMS SEQUENCE OBJECT to get the sequence), and I don't want
    one application contains two connection at the same time. Is the any way I
    can do?
    Marc Prud'hommeaux wrote:
    Maguohai-
    The SequenceFactory implementation should use a second Connection in order
    to manipulate sequence numbers, since the transactional boundry for
    the sequence increment should not be bound to the transactional boundry of
    the PersistenceManager.
    In article <bbu83a$knd$[email protected]>, maguohai wrote:
    In SequenceFactory interface the following method
    public long getNext(Class cls, Connector connector)
    is to get the next sequence number, and one can use the connector to get a
    new connection, but at most time, when the kodo call this method, there
    must a PM exist, so if I want to use the connection with the exist PM, not
    a new connection, how can I get to it!
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • How to get DP name via script

    Hello,
    We are migrating from Symantec Altiris to SCCM 2012. In our current environment we have both HP models and now moving towards Lenovo models. We are using both respective Enterprise solutions for managing driver that is HP SSM and Lenovo Thininstaller.
    We have 3 sites/locations with exactly the same shares on each one. We are using a script with a built in Altiris token that finds out what DP or Taskserver (in Altiris Environment) the client is connected to.
    How can I define a DP with the same type of script in SCCM?
    Are there any tokens for DP?
    Are there any specific local files or usuble values that changes when connecting to other DPs?
    Can I somehow query bounderies in a script and then use IF statement to connect them to a specific share?
    I know that I can use one share if I want to but that will use a lot of network trafic since we have the DPs on different locations throughout the country. One idea I had was to make 3 different packages with one DP specified in each
    one and then connect them to its specific boundary.  
    The good part to make it work all in one script is that it can be applied to any client in the organisation to update their current drivers and not just to use in initial deployment.
    I found a vbs script that can echo a DP, but how do I implement it into my script?
    http://sccmguru.wordpress.com/2014/04/22/show-dp-in-use-during-task-sequence/
    '// Purpose: Used to find active Distribution Point
    '// Version: 1.0 - April 15, 2014 - Odd-Magne Kristoffersen
    '// This script is provided "AS IS" with no warranties
    Set env = CreateObject("Microsoft.SMS.TSEnvironment")
    ENV_SMSTSHTTPTHI0000D = env("_SMSTSHTTPTHI0000D")
    SMSTSHTTPTHI0000D = Split(ENV_SMSTSHTTPTHI0000D,"/",-1,1)
    DP = split(SMSTSHTTPTHI0000D(2),".",-1,1)
    Echo DP(0)  
    Here is my script in short format. I didn't bother putting all the models.
    The value %MODEL% is from the Query in the beginning of the script and the %TASKSERVER% value is an Altiris token the can be used when running a script with the agent credentials.
    @echo off
    set model=
    FOR /F "tokens=2 delims='='" %%A in ('wmic ComputerSystem Get Model /value') do SET model=%%A
    Echo This is a %MODEL%
    IF "%MODEL%" == "HP EliteBook 820 G1" GOTO HP Updates
    IF "%MODEL%" == "HP EliteBook 840 G1" GOTO HP Updates
    IF "%MODEL%" == "HP Compaq 8000 Elite SFF PC" GOTO HP Updates
    IF "%MODEL%" == "HP Compaq 8100 Elite SFF PC" GOTO HP Updates
    IF "%MODEL%" == "HP Compaq 8200 Elite SFF PC" GOTO HP Updates
    IF "%MODEL%" == "HP Compaq Elite 8300 SFF" GOTO HP Updates
    IF "%MODEL%" == "20AQ007UMS" GOTO Lenovo Updates
    IF "%MODEL%" == "20AL00BYMS" GOTO Lenovo Updates
    IF "%MODEL%" == "10AB000YMX" GOTO Lenovo Updates
    IF "%MODEL%" == "20C0003TMS" GOTO Lenovo Updates
    IF "%MODEL%" == "20AL007NMS" GOTO Lenovo Updates
    IF "%MODEL%" == "10AAS0HN00" GOTO Lenovo Updates
    exit 1
    :Hp Updates
    \\%TASKSERVER%\Share\ssm.exe \\%TASKSERVER%\Share /ACCEPT /INSTALL /DEBUG /TITLE:"HP Updates" /NOREBOOT
    RMDIR "c:\ssm" /s /q
    exit 0
    :Lenovo Updates
    xcopy \\%TASKSERVER%\Share\Thininstaller c:\Thininstaller /S /H /I /Y
    c:\Thininstaller\Thininstaller.exe /CM -search A -action INSTALL -repository \\%TASKSERVER%\Share\Repository-noicon -includerebootpackages 0,3 -showprogress -noreboot
    RMDIR "c:\Thininstaller" /s /q
    exit 0

    The way these two driver management systems work is that the exe is not installed, only executed with different switches to look inside a share with drivers to match what is installed on the client and apply the missing drivers.
    I have checked other threads with HP ssm and Lenovo Thininstaller regarding SCCM implementation and they all create a package for the exe and apply the command switches. Exactly as many of you already described here.
    That works if you have only ONE share. I manage 3 shares, one for each geographical location that we prep Windows installations. This to make it faster for the client to download the drivers and to not use/load the WAN unnecessarily.
    I read on another thread that I can't query a dp because it's assigned only when the client requires content. 
    The only workaround as I see it is to:
    1. Create 3 different packages with different  shares in the command line. And somehow apply a detection method in the task sequence to figure out location (DP, IP, DNS, boundary, Assigned Domain Controller).
    2. Create 3 different packages and 3 different roles in MDT, one for every location. 
    3. Only use one share on the location that mostly is used for Windows installations and accept that it will take longer for the drivers to be applied on the other locations. 
    Which one should I go for?
    Many of you may think that I should use the standard way of managing drivers in SCCM. But this is so much easier. I never have to package drivers or hardware applications like HP Connection Manager. I can reapply the package to any client in production and
    update the drivers and model specific applications if needed.

Maybe you are looking for

  • Photoshop CS4 in Windows 7 bug runing batch actions

    I been using Photoshop CS4 in Vista with no problems, but now my problem is when I installed windows 7 and opened 60 photos and apply an action and try to do other things while PS is working in the batch, when I try to change to other window I get ba

  • Jdev 10.1.3 and JSF  "comandlink component" don't work with Data filter

    I´m working in JSF with Jdeveloper 10.1.3 and Oc4j . I have a problem. I have .jspx where display employees of the company. The field employeeid have "comandlink component" with action "control.editemployee" when I fetch all data comandlink work OK.

  • How to locate the lost iphone using pc?

    how to locate the lost iphone using pc?

  • What is "Other" in iTunes?

    I just got an iPhone 5s today i was playing on it all day. When the day was over I synced it to my Mac and it had a yellow bar that said "other". I know this is like caches, browsing histories, etc. but it is taking up 4GB of space. I do use Dropbox,

  • Converting SQL to PS Query

    I have this piece of code in an Oracle SQL and I want to convert to PS Query.  Not sure how to do this.  Any help would be greatly appreciated. from ps_audit_ax_names a left join     (select b.emplid, b.effdt, b.name from ps_names b         where b.e