Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Remote server Request

Reply
Thread Tools

Remote server Request

 
 
arunkumar.mit@gmail.com
Guest
Posts: n/a
 
      11-06-2006
Hi all,

I am beginner in httpunit, While writing test case for an web
application on remote server, I am not able to get request from remote
server. Iam getting IO err as java.io.IOException. How can i resolve
it.

The code which i have written is

import com.meterware.httpunit.*;
import java.io.*;

/** This is a simple example of using HttpUnit to read web pages. **/
public class Aak2 {


public static void main( String[] params ) {

try {

WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest( "http://netbeans.org" );
WebResponse resp = wc.getResponse( req );
System.out.println( resp.getText() );

}catch (java.net.MalformedURLException e) {
System.out.println("Bad url: " + e);
}
catch (IOException e) {
System.out.println("IO Err: " + e);
}
catch (org.xml.sax.SAXException e) {
System.out.println("XML Err: " + e);
}
}
}

Regards,

Arun

 
Reply With Quote
 
 
 
 
Manish Pandit
Guest
Posts: n/a
 
      11-06-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> server. Iam getting IO err as java.io.IOException. How can i resolve
> it.


It'll help if you could paste the exception trace. Is it possible that
you are behind a proxy, and java cannot make a direct connection? You
can try writing a simple program that connects to, lets say,
www.google.com and prints out what it got? This will verify the
connectivity.

-cheers,
Manish

 
Reply With Quote
 
 
 
 
A761208@163.com
Guest
Posts: n/a
 
      11-07-2006
I have no IO err but some JS err.
ConversionError: The undefined value has no properties. (httpunit; line
2)
at
org.mozilla.javascript.NativeGlobal.constructError (NativeGlobal.java:597)
at
org.mozilla.javascript.NativeGlobal.constructError (NativeGlobal.java:557)
at
org.mozilla.javascript.ScriptRuntime.getProp(Scrip tRuntime.java:712)
at org.mozilla.javascript.gen.c40.call(httpunit:2)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRu ntime.java:1191)
at org.mozilla.javascript.gen.c43.call(httpunit:6)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRu ntime.java:1191)
at org.mozilla.javascript.gen.c48.call(httpunit:14)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRu ntime.java:1191)
at org.mozilla.javascript.gen.c49.call(httpunit:0)
at org.mozilla.javascript.gen.c49.exec(httpunit)
at org.mozilla.javascript.Context.evaluateReader(Cont ext.java:820)
at org.mozilla.javascript.Context.evaluateString(Cont ext.java:784)
at
com.meterware.httpunit.javascript.JavaScript$JavaS criptEngine.executeScript(JavaScript.java:132)
at
com.meterware.httpunit.scripting.ScriptableDelegat e.runScript(ScriptableDelegate.java:65)
at
com.meterware.httpunit.parsing.ScriptFilter.getTra nslatedScript(ScriptFilter.java:151)
at
com.meterware.httpunit.parsing.ScriptFilter.endEle ment(ScriptFilter.java:131)
at org.cyberneko.html.filters.DefaultFilter.endElemen t(Unknown Source)
at org.cyberneko.html.filters.NamespaceBinder.endElem ent(Unknown
Source)
at org.cyberneko.html.HTMLTagBalancer.callEndElement( Unknown Source)
at org.cyberneko.html.HTMLTagBalancer.endElement(Unkn own Source)
at org.cyberneko.html.HTMLScanner$SpecialScanner.scan (Unknown Source)
at org.cyberneko.html.HTMLScanner.scanDocument(Unknow n Source)
at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at
com.meterware.httpunit.parsing.NekoHTMLParser.pars e(NekoHTMLParser.java:41)
at com.meterware.httpunit.HTMLPage.parse(HTMLPage.jav a:255)
at
com.meterware.httpunit.WebResponse.getReceivedPage (WebResponse.java:1109)
at com.meterware.httpunit.WebResponse.getFrames(WebRe sponse.java:109
at
com.meterware.httpunit.WebResponse.getFrameRequest s(WebResponse.java:875)
at
com.meterware.httpunit.FrameHolder.updateFrames(Fr ameHolder.java:179)
at
com.meterware.httpunit.WebWindow.updateFrameConten ts(WebWindow.java:252)
at
com.meterware.httpunit.WebClient.updateFrameConten ts(WebClient.java:485)
at com.meterware.httpunit.WebWindow.updateWindow(WebW indow.java:146)
at
com.meterware.httpunit.WebWindow.getSubframeRespon se(WebWindow.java:130)
at com.meterware.httpunit.WebWindow.getResponse(WebWi ndow.java:121)
at com.meterware.httpunit.WebClient.getResponse(WebCl ient.java:113)
at test.main(test.java:14)
Exception in thread "main" com.meterware.httpunit.ScriptException:
Script '(function(){
function m(b){return b!=null?'"'+b+'"':'""'}function B(b){if(typeof
encodeURIComponent=="function"){return
encodeURIComponent(b)}else{return escape(b)}}function
c(b,a){if(a){window.google_ad_url+="&"+b+"="+a}}fu nction
f(b,a){if(a){c(b,B(a))}}function l(b,a,d){if(a&&typeof
a=="object"){a=a[d%a.length]}c("color_"+b,a)}function D(b,a){var
d=b.screen,g=navigator.javaEnabled(),e=-a.getTimezoneOffset();if(d){c("u_h",d.height);c("u _w",d.width);c("u_ah",d.availHeight);c("u_aw",d.av ailWidth);c("u_cd",d.colorDepth)}c("u_tz",
e);c("u_his",history.length);c("u_java",g);if(navi gator.plugins){c("u_nplug",navigator.plugins.lengt h)}if(navigator.mimeTypes){c("u_nmime",navigator.m imeTypes.length)}}function
y(b){b=b.toLowerCase();if(b.substring(0,3)!="ca-"){b="ca-"+b}return
b}function
G(b,a,d){d=d.substring(0,1000);d=d.replace(/%\w?$/,"");if(b.google_ad_output=="js"&&(b.google_ad_req uest_done||b.google_radlink_request_done)){a.write ('<script
language="JavaScript1.1" src='+m(d)+"><\/script>")}else
if(b.google_ad_output=="html"){if(b.name!=
"google_ads_frame"){a.write('<iframe name="google_ads_frame"
width='+m(b.google_ad_width)+" height="+m(b.google_ad_height)+"
frameborder="+m(b.google_ad_frameborder)+" src="+m(d)+' marginwidth="0"
marginheight="0" vspace="0" hspace="0" allowtransparency="true"
scrolling="no">');a.write("</iframe>")}}else
if(b.google_ad_output=="textlink"){a.write('<scrip t
language="JavaScript1.1" src='+m(d)+"><\/script>")}}function F(b){var
a=null;b.google_ad_frameborder=a;b.google_ad_forma t=a;b.google_page_url=a;
b.google_language=a;b.google_gl=a;b.google_country =a;b.google_region=a;b.google_city=a;b.google_hint s=a;b.google_safe=a;b.google_encoding=a;b.google_a d_output=a;b.google_max_num_ads=a;b.google_ad_chan nel=a;b.google_contents=a;b.google_alternate_ad_ur l=a;b.google_alternate_color=a;b.google_color_bg=a ;b.google_color_text=a;b.google_color_link=a;b.goo gle_color_url=a;b.google_color_border=a;b.google_c olor_line=a;b.google_adtest=a;b.google_kw_type=a;b .google_kw=a;b.google_num_radlinks=a;b.google_max_ radlink_len=
a;b.google_rl_filtering=a;b.google_rl_mode=a;b.goo gle_rt=a;b.google_ad_type=a;b.google_image_size=a; b.google_feedback=a;b.google_skip=a;b.google_page_ location=a;b.google_referrer_url=a;b.google_ad_reg ion=a;b.google_ad_section=a;b.google_bid=a;b.googl e_cpa_choice=a;b.google_cust_age=a;b.google_cust_g ender=a;b.google_cust_interests=a;b.google_cust_id =a;b.google_cust_job=a;b.google_cust_u_url=a}funct ion
A(){var b=null,a=window,d=document,g=new
Date,e=g.getTime(),j=a.google_ad_format;if(a.googl e_cpa_choice){a.google_ad_url=
"http://pagead2.googlesyndication.com/cpa/ads?";a.google_ad_url+="client="+escape(y(a.google _ad_client));a.google_ad_region="_google_cpa_regio n_";c("cpa_choice",a.google_cpa_choice);if(typeo f
d.characterSet!="undefined"){f("oe",d.characterSet )}else if(typeof
d.charset!="undefined"){f("oe",d.charset)}}else{a. google_ad_url="http://pagead2.googlesyndication.com/pagead/ads?";a.google_ad_url+="client="+escape(y(a.google _ad_client))}var
k=a.google_num_slots_by_client,w=a.google_num_slot s_by_channel,i=a.google_prev_ad_formats_by_region;
a.onerror=a.google_org_error_handler;if(a.google_a d_region==b&&a.google_ad_section!=b){a.google_ad_r egion=a.google_ad_section}var
h=a.google_ad_region==b?"":a.google_ad_region,q=fa lse;if(j){q=j.indexOf("_0ads")>0}if(q){if(a.google _num_0ad_slots){a.google_num_0ad_slots=a.google_nu m_0ad_slots+1}else{a.google_num_0ad_slots=1}if(a.g oogle_num_0ad_slots>3){return}}else
if(!a.google_cpa_choice){if(a.google_num_ad_slots) {a.google_num_ad_slots=a.google_num_ad_slots+1}els e{a.google_num_ad_slots=1}if(a.google_num_slots_to _rotate){i[h]=
b;if(a.google_num_slot_to_show==b){a.google_num_sl ot_to_show=e%a.google_num_slots_to_rotate+1}if(a.g oogle_num_slot_to_show!=a.google_num_ad_slots){ret urn}}else
if(a.google_num_ad_slots>3&&h==""){return}}c("dt", g.getTime());c("hl",a.google_language);if(a.google _country){c("gl",a.google_country)}else{c("gl",a.g oogle_gl)}c("gr",a.google_region);f("gcs",a.google _city);f("hints",a.google_hints);c("adsafe",a.goog le_safe);c("oe",a.google_encoding);c("lmt",a.googl e_last_modified_time);f("alternate_ad_url",
a.google_alternate_ad_url);c("alt_color",a.google_ alternate_color);c("skip",a.google_skip);var
n=a.google_ad_client;if(!k[n]){k[n]=1;k.length+=1}else{k[n]+=1}if(i[h]){f("prev_fmts",i[h].toLowerCase());if(k.length>1){c("slot",k[n])}}if(j){f("format",j.toLowerCase());if(i[h]){i[h]=i[h]+","+j}else{i[h]=j}}c("num_ads",a.google_max_num_ads);c("output",a .google_ad_output);c("adtest",a.google_adtest);if( a.google_ad_channel){var
r=a.google_ad_channel.toLowerCase();f("channel",r) ;var
s="",t=r.split("+");for(var o=
0;o<t.length;o++){var
p=t[o];if(!w[p]){w[p]=1}else{s+=p+"+"}}f("pv_ch",s)}f("url",a.google_pa ge_url);l("bg",a.google_color_bg,e);l("text",a.goo gle_color_text,e);l("link",a.google_color_link,e); l("url",a.google_color_url,e);l("border",a.google_ color_border,e);l("line",a.google_color_line,e);c( "kw_type",a.google_kw_type);f("kw",a.google_kw);f( "contents",a.google_contents);c("num_radlinks",a.g oogle_num_radlinks);c("max_radlink_len",a.google_m ax_radlink_len);c("rl_filtering",a.google_rl_filte ring);c("rl_mode",
a.google_rl_mode);c("rt",a.google_rt);c("ad_type", a.google_ad_type);c("image_size",a.google_image_si ze);c("region",a.google_ad_region);c("feedback_lin k",a.google_feedback);f("ref",a.google_referrer_ur l);f("loc",a.google_page_location);c("bid",a.googl e_bid);c("cust_age",a.google_cust_age);c("cust_gen der",a.google_cust_gender);c("cust_interests",a.go ogle_cust_interests);c("cust_id",a.google_cust_id) ;c("cust_job",a.google_cust_job);c("cust_u_url",a. google_cust_u_url);if(z(a,d)&&d.body){var
u=d.body.scrollHeight,
v=d.body.clientHeight;if(v&&u){f("cc",Math.round(v *100/u))}}D(a,g);G(a,d,a.google_ad_url);F(a)}function
C(b,a,d){A();return true}function z(b,a){return
b.top.location==a.location}function x(b,a){var
d=a.documentElement;if(z(b,a))return
false;if(b.google_ad_width&&b.google_ad_height){va r
g=1,e=1;if(b.innerHeight){g=b.innerWidth;e=b.inner Height}else
if(d&&d.clientHeight){g=d.clientWidth;e=d.clientHe ight}else
if(a.body){g=a.body.clientWidth;e=a.body.clientHei ght}if(e>2*b.google_ad_height||g>2*b.google_ad_wid th){return
false}}return true}
function E(){var
b=window,a=document,d=a.location,g=a.referrer,e=nu ll;b.google_org_error_handler=b.onerror;b.onerror= C;if(b.google_ad_frameborder==e){b.google_ad_frame border=0}if(b.google_ad_output==e){b.google_ad_out put="html"}if(b.google_ad_format==e&&b.google_ad_o utput=="html"){b.google_ad_format=b.google_ad_widt h+"x"+b.google_ad_height}if(b.google_page_url==e){ b.google_page_url=g;if(!x(b,a)){b.google_page_url= d;b.google_last_modified_time=Date.parse(a.lastMod ified)/1000;b.google_referrer_url=
g}}else{b.google_page_location=g;if(!x(b,a)){b.goo gle_page_location=d}}if(b.google_num_slots_by_chan nel==e){b.google_num_slots_by_channel=[]}if(b.google_num_slots_by_client==e){b.google_num_ slots_by_client=[]}if(b.google_prev_ad_formats_by_region==e){b.googl e_prev_ad_formats_by_region=[]}}E();A();
})()' failed: ConversionError: The undefined value has no properties.
(httpunit; line 2)
at
com.meterware.httpunit.javascript.JavaScript$JavaS criptEngine.handleScriptException(JavaScript.java: 202)
at
com.meterware.httpunit.javascript.JavaScript$JavaS criptEngine.executeScript(JavaScript.java:136)
at
com.meterware.httpunit.scripting.ScriptableDelegat e.runScript(ScriptableDelegate.java:65)
at
com.meterware.httpunit.parsing.ScriptFilter.getTra nslatedScript(ScriptFilter.java:151)
at
com.meterware.httpunit.parsing.ScriptFilter.endEle ment(ScriptFilter.java:131)
at org.cyberneko.html.filters.DefaultFilter.endElemen t(Unknown Source)
at org.cyberneko.html.filters.NamespaceBinder.endElem ent(Unknown
Source)
at org.cyberneko.html.HTMLTagBalancer.callEndElement( Unknown Source)
at org.cyberneko.html.HTMLTagBalancer.endElement(Unkn own Source)
at org.cyberneko.html.HTMLScanner$SpecialScanner.scan (Unknown Source)
at org.cyberneko.html.HTMLScanner.scanDocument(Unknow n Source)
at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at
com.meterware.httpunit.parsing.NekoHTMLParser.pars e(NekoHTMLParser.java:41)
at com.meterware.httpunit.HTMLPage.parse(HTMLPage.jav a:255)
at
com.meterware.httpunit.WebResponse.getReceivedPage (WebResponse.java:1109)
at com.meterware.httpunit.WebResponse.getFrames(WebRe sponse.java:109
at
com.meterware.httpunit.WebResponse.getFrameRequest s(WebResponse.java:875)
at
com.meterware.httpunit.FrameHolder.updateFrames(Fr ameHolder.java:179)
at
com.meterware.httpunit.WebWindow.updateFrameConten ts(WebWindow.java:252)
at
com.meterware.httpunit.WebClient.updateFrameConten ts(WebClient.java:485)
at com.meterware.httpunit.WebWindow.updateWindow(WebW indow.java:146)
at
com.meterware.httpunit.WebWindow.getSubframeRespon se(WebWindow.java:130)
at com.meterware.httpunit.WebWindow.getResponse(WebWi ndow.java:121)
at com.meterware.httpunit.WebClient.getResponse(WebCl ient.java:113)
at test.main(test.java:14)

 
Reply With Quote
 
A761208@163.com
Guest
Posts: n/a
 
      11-07-2006
And if I get a html with no js, there is no err.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
The remote server returned an error: (400) Bad Request. archana ASP .Net 0 12-18-2006 12:54 PM
HttpWebRequest is giving: "Error on HTTP request: The remote server returned an error: (403) Forbidden." edsuslen@yahoo.com ASP .Net 2 09-27-2005 12:17 PM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Wireless Networking 1 12-11-2004 09:09 PM
Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How??? Brian Birtle ASP .Net 2 10-16-2003 02:11 PM



Advertisments