| Download a webpage that contains javascript |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- Recognize Windows ShutdownHi,
how can i recognize that Windows is shutting down (when i'm logged off)?
Sorry for stupid questions, but i didn't found the right solution!
Greets,
Nico
-> remove the underscores in the email <-
- 7
- java/81177: java patch server down
>Number: 81177
>Category: java
>Synopsis: java patch server down
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: freebsd-java
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Tue May 17 20:30:07 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Ron
>Release: FreeBSD 5.4-STABLE i386
>Organization:
>Environment:
System: FreeBSD justok.thuisnetwerk.nl 5.4-STABLE FreeBSD 5.4-STABLE #0: Sat May 14 16:24:15 CEST 2005 email***@***.com:/usr/obj/usr/src/sys/MYKERNEL i386
>Description:
jdk14 and jdk15 can not be installed, because http://www.eyesbeyond.com/freebsddom/java/jdk15.html is down.
<code/input/activities to reproduce the problem (multiple lines)>
Use any webbrowser to visit the URL, and see that it's down.
>How-To-Repeat:
>Fix:
Someone should bring up the webserver or let the URL point to a webserver that is up.
>Release-Note:
>Audit-Trail:
>Unformatted:
- 7
- newbie java/OOP questionPerhaps someone here can help me with this, I tried asking someone else
about this but couldn't quite describe my question.
I understand that this syntax calls a method on behalf of an object:
b1.method();
but in some java example code I see stuff like this (from a link list app) :
answer.head = IntNode.listCopy(head);
I know that "head" is an instance variable of the class, specfically an
IntNode. I also know that "answer" is a method variable of the type
IntLinkedBag.
My question is: what the heck is going on during the "answer.head"
operation? I don't understand how answer is interacting with head.
They're just two objects. What does the period do when it connects two
objects?
Any pointers or keywords to look up would be apprecited.
--
Mike
Block Banner Ads Now
http://everythingisnt.com/hosts.html
- 7
- Implementing inheritance in JAVAHi,
I am a naive JAVA user. Can you please tell me, oh how to implement
the following scenario
A
^ ^
/ \
B C
^ ^
\ /
D
Classes B and C extends class A, but how to define class D, such that
members of both B and C are available to D.
Thanks
>> manjunath
- 8
- JDO nad MYSQLHello.
Im looking form examples usage JDO (opensource) to MYSQL. It's possible to
it ???
Where can I find it ???
Thanks for Your help
E.N
- 8
- Doubt regarding InterfacesThanks everyone for your replies!
I have a basic question - in the above instance Runnable is an
interface and interfaces cannot be instantiated. So something like 'new
Runnable()' seems puzzling to me. Is this syntax for instantiating an
object of the Anonymous class?
Also, is the above snippet similar to the following in the end result:
class ac implements Runnable{
public void run() {
System.out.println("Hello World on " +
Thread.currentThread());
}
};
ac doHelloWorld = new ac();
- 10
- SET CLASSPATHhi, i'm using the abstract class definition, and when compiling the abstract
class it's ok, but the problem is when compiling the subclass: i get the
following message:
Rect.java:9: cannot resolve symbol
symbol : class GeoFigure
location: class figures.Rect
public class Rect extends GeoFigure
^
1 error
the abstract class is called: GeoFigure;
and the subclass is Rect
so how cn use the set classpath at command line, should it include the
directory where are located all the package files(the abstract class and
subclass .java files), or should it point at onel evel before the directory
that contains the package files?
thank's!
--
SAID BARA
- 11
- changing the classpath at runtime in codeIs it possible for a java app to change it's classpath at runtime. I
tried:
System.setProperty("java.class.path","foo")
The reason for wanting to try is URLClassLoader will not physically
reread a class file if it is in the classpath. See
http://groups.google.com/group/comp.lang.java.programmer/browse_thread/thread/793a9146df18365a/ceaa154348f6f271#ceaa154348f6f271
- 11
- Removing Item From JList - getSelectedIndex problemHi all,
I am currently working on a JList that populates data into a JList
from a CSV file. I have a button that is supposed to get the Selected
index and then delete that item from the JList. Below is the code that
I am using:
int index = lstComputerExceptions.getSelectedIndex();
System.out.println("index is: " + index);
model.remove(0);
int size = model.getSize();
if (size == 0) { //Nobody's left, disable firing.
btnDelete.setEnabled(false);
} else { //Select an index.
if (index == model.getSize()) {
//removed item in last position
index--;
}
lstComputerExceptions.setSelectedIndex(index);
lstComputerExceptions.ensureIndexIsVisible(index);
}
I have printed out what index is and no matter what item I have in the
Jlist I have selected it will always print out
-1. Therefore keeps on causing my program to crash and not delete the
item out of the Jlist.
Any help in this matter would be highly appreicated.
Thank you
- 12
- Welcome Back Roedy Green!Have you been back for awhile? (Maybe I'm just stupid!)
I was . . surprised to see a post from you
:)
- 12
- Making Internet DialerGreetings;
I am trying to build a windows internet dialer... I have gained
control of my modem through javax.comm API and I can dial a number
through my modem... the problem is I can not figure out how to pass
the username and password to my ISP.
I want to know what steps are involved in getting connected to my
isp... and also I want my windows O/S to know that i am connected.
Any resource given will be helpful.
I hope someone can help me in this regard.
Thanks
- 12
- J2ME HTTP Post Method ProblemHello,
I built a midlet that sends an information by POST method in HTTP
connection.
in the emulators (such as Nokia 6270,6230, 6230i..) I See the "post
data" in the diagnostic, but the data doesn't arrive to the server. I
tried several servers and they didn't work. I tried to run the SDK's on
different computers and it was the same.
If I run my midlet on my Cellphone (6230) everything works fine.
Example for the post data:
action=Login&Username=tony&password=1234
is a known problem?
Any suggestions on how to solve it ?
Here is additional information:
My J2ME Code:
String params = new String("action=Login&username=&password=");
httpConn = (HttpConnection)Connector.open(url, Connector.READ_WRITE );
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("Content-Type", "text/plain");
os = httpConn.openOutputStream();
byte postmsg[] = params.getBytes();
for(int i=0;i<postmsg.length;i++) {
os.write(postmsg[i]);
}
os.flush();
StringBuffer sb = new StringBuffer();
is = httpConn.openDataInputStream();
int chr;
while ((chr = is.read()) != -1) {
sb.append((char) chr);
}
response = new String(sb.toString().getBytes(),"UTF-8");
Here is Simple PHP file which is on the server:
<?php
header('Content-type: text/plain');
if ($_POST["action"]=="Login") {
if($_POST["username"]=='tony') {
echo "<?xml version=\"1.0\"?>\n";
echo "<dictionary>\n";
echo "<Status>1</Status>\n";
echo "<Reason>0</Reason>\n";
echo "<Key>JFKDL54GFDYU85T43NJKGH89N543KGFD</Key>\n";
echo "</dictionary>\n";
exit;
}
else {
echo "<?xml version=\"1.0\"?>\n";
echo "<dictionary>\n";
echo "<Status>0</Status>\n";
echo "<Reason>Wrong Username</Reason>\n";
echo "</dictionary>\n";
exit;
}
}
echo "Not Good!";
?>
When I run the midlet on my cellphone, the server recognize the value
of $_POST["action"]
but when I run the midlet on the emulators, the server doesn't
recognize the value of $_POST["action"]. in other words, the server
doesn't get the string.
But, when I look in the Diagnostic of the emulator I see that the data
were sent.
Here is the log of the Request operation:
Location = [http://10.0.0.101/dic.php]
Request Method = [POST]
Post Data = [action=Login&username=&password=]
Headers (8)
Host = [10.0.0.101]
Content-Type = [ text/plain]
User-Agent = [ Nokia6270/2.0 (p03.20) Profile/MIDP-2.0
Configuration/CLDC-1.1 Profile/MIDP-1.0 Confirguration/CLDC-1.0,
Nokia6270/2.0 (p03.20) Profile/MIDP-2.0 Configuration/CLDC-1.1
UNTRUSTED/1.0]
Content-Length = [ 32]
Connection = [ Keep-Alive]
x-wap-profile = [
"http://nds1.nds.nokia.com/uaprof/N6270r100.xml"]
Here is the log og the response:
Request Status = 200: "OK"
Location = [http://10.0.0.101/dic.php]
Headers (6)
Transfer-Encoding = [ chunked]
Date = [ Tue, 13 Jun 2006 23:30:08 GMT]
Content-Type = [ text/plain]
Server = [ Apache/1.3.33 (Unix) PHP/4.3.10]
X-Powered-By = [ PHP/4.3.10]
Via = [ 1.1 Bezeq-L2TP-MED-Stack1 (NetCache NetApp/5.6.2R1)]
Content Data: 9 bytes, text/plain; ISO-8859-1
Not Good!
(The Not good is the string that appears in the end of the php. we get
there only if the "IF" statment is false.
- 13
- How can JComboBox listener to MouseEvent?
Since JComboBox and JButton both are
extends from JComponent.
When I addMouseListener(this);
for jButton, it listens to the MouseEvent.
But jComboBox doesn't listen to the MouseEvent.
public void mouseEntered(MouseEvent me) {
System.out.println("mouse entered");
jComboBox.setToolTipText("mouse entered"); // not work
jButton.setToolTipText("mouse entered button"); // works fine
}
mouseEntered just move your mouse pointer on
the object, no need to click (pressed and released).
I just want to detect the mouse entered on JComboBox
(i.e. popup a ToolTip) before I click it for select an item.
Do I miss something? Do I need to setXXX and/or enableXXX
JComboBox before I addMouseListener?
Thank Q for your help!
- 14
- emailtosmsemail***@***.com wrote:
> Anyone know how to send sms from email i [sic] mean email to sms
Set the phone number as the destination address, according to the standard
mapping of phone numbers to email addresses set by the devices service provider.
--
Lew
- 15
- changing code while program is runningHello,
I would like to have my class code loaded into application, which is
already running. I tried something like this:
public class Main
{
...
private void reloadClass() throws Exception
{
new Pair("","").print(); //class to be reloaded
System.in.read (); //interval - here comes manual class recompilation
ClassLoader.getSystemClassLoader ().loadClass ("Pair"); //reload class
new Pair("","").print(); //check if new version loaded
}
}
It seems that ClassLoader.loadClass checks the presence of the Pair
class in memory and doesn't relod it. How to omit it?
regards
blacky
|
| Author |
Message |
googleaddress

|
Posted: 2004-9-14 4:20:00 |
Top |
java-programmer, Download a webpage that contains javascript
I am trying to download the html page at
http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1
Using the code
public class DownloadWebPage
{ public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1");
BufferedReader webRead = new BufferedReader(new
InputStreamReader(url.openStream()));
String line;
while ((line = webRead.readLine()) != null)
{
System.out.println(line);
}
}
}
But all I am getting is
<HTML><HEAD><SCRIPT
LANGUAGE="JAVASCRIPT">location.replace("http://www.dreamteamfc.com");</SCRIPT></HEAD></HTML>
I'm guessing that when the web brower meets this code it executes the
javascript
location.replace("http://www.dreamteamfc.com")
And somehow loads the web page.
How do I go about downloading the actual web page that gets displayed
in a normal web browser.
Any help appeciated!
pat
|
| |
|
| |
 |
Chander

|
Posted: 2004-9-14 6:15:00 |
Top |
java-programmer >> Download a webpage that contains javascript
Have you checked its behavious whenyou try opening on Browser..? it
redirects you to someother page and checks if you are logged in.. etc etc..
The way you are doing is not the proper way you have to follow the RFC
for HTTP1.1 for the same... the procedure used by you might work for
some sites but not for all the sites....
Cheers
http://www.ziksa.net
email: email***@***.com
Patrick wrote:
> I am trying to download the html page at
>
> http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1
>
> Using the code
>
> public class DownloadWebPage
> { public static void main (String[] args) throws IOException
> {
> URL url = new
> URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1");
> BufferedReader webRead = new BufferedReader(new
> InputStreamReader(url.openStream()));
> String line;
> while ((line = webRead.readLine()) != null)
> {
> System.out.println(line);
> }
>
> }
> }
>
> But all I am getting is
>
>
> <HTML><HEAD><SCRIPT
> LANGUAGE="JAVASCRIPT">location.replace("http://www.dreamteamfc.com");</SCRIPT></HEAD></HTML>
>
>
> I'm guessing that when the web brower meets this code it executes the
> javascript
>
>
> location.replace("http://www.dreamteamfc.com")
>
>
> And somehow loads the web page.
>
>
> How do I go about downloading the actual web page that gets displayed
> in a normal web browser.
>
>
>
>
> Any help appeciated!
>
>
> pat
|
| |
|
| |
 |
googleaddress

|
Posted: 2004-9-14 22:50:00 |
Top |
java-programmer >> Download a webpage that contains javascript
I had a mistake in my previous post, it should have read:
If I navigate to
http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH
And click on a link which calls the follow javascript function
"javascript:dt_pop('PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167',
'remote', 610, 550, 10, 10, 'no', 'yes', 'no', 'no'); "
A new page pops up, the browser say its url is
http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167
Now with my code
public class DownloadWebPage
{ public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1");
BufferedReader webRead = new BufferedReader(new
InputStreamReader(url.openStream()));
String line;
while ((line = webRead.readLine()) != null)
{
System.out.println(line);
}
}
}
I can download the page at
http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH
But I cannot download the page at
http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167
That the javascript function
"javascript:dt_pop('PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167',
'remote', 610, 550, 10, 10, 'no', 'yes', 'no', 'no'); "
In the page
http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH
calls.
When I try to download
http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167
With my code, all i get is
<HTML><HEAD><SCRIPT
LANGUAGE="JAVASCRIPT">location.replace("http://www.dreamteamfc.com");</SCRIPT></HEAD></HTML>
So how do i go about downloading the contents of the html page that is
in the window that is displayed when the javascript function above is
called?
regards,
pat
Chander <email***@***.com> wrote in message news:<7_o1d.6844$email***@***.com>...
> Have you checked its behavious whenyou try opening on Browser..? it
> redirects you to someother page and checks if you are logged in.. etc etc..
>
> The way you are doing is not the proper way you have to follow the RFC
> for HTTP1.1 for the same... the procedure used by you might work for
> some sites but not for all the sites....
>
> Cheers
>
> http://www.ziksa.net
> email: email***@***.com
>
> Patrick wrote:
> > I am trying to download the html page at
> >
> > http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1
> >
> > Using the code
> >
> > public class DownloadWebPage
> > { public static void main (String[] args) throws IOException
> > {
> > URL url = new
> > URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1");
> > BufferedReader webRead = new BufferedReader(new
> > InputStreamReader(url.openStream()));
> > String line;
> > while ((line = webRead.readLine()) != null)
> > {
> > System.out.println(line);
> > }
> >
> > }
> > }
> >
> > But all I am getting is
> >
> >
> > <HTML><HEAD><SCRIPT
> > LANGUAGE="JAVASCRIPT">location.replace("http://www.dreamteamfc.com");</SCRIPT></HEAD></HTML>
> >
> >
> > I'm guessing that when the web brower meets this code it executes the
> > javascript
> >
> >
> > location.replace("http://www.dreamteamfc.com")
> >
> >
> > And somehow loads the web page.
> >
> >
> > How do I go about downloading the actual web page that gets displayed
> > in a normal web browser.
> >
> >
> >
> >
> > Any help appeciated!
> >
> >
> > pat
|
| |
|
| |
 |
Chander

|
Posted: 2004-9-15 11:33:00 |
Top |
java-programmer >> Download a webpage that contains javascript
As I menatined earlier read the rfc for http 1.1 when you are requesting
a page firsdt you get is the header you get information for size of the
data to follow, if server has responded as error, what type of error..
or the page is to be redirected, etc.. as per these information you are
to read the following lines or resend the request to the other page as
direction in the header..
Cheers
Patrick wrote:
> I had a mistake in my previous post, it should have read:
>
> If I navigate to
> http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH
>
>
> And click on a link which calls the follow javascript function
> "javascript:dt_pop('PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167',
> 'remote', 610, 550, 10, 10, 'no', 'yes', 'no', 'no'); "
>
>
> A new page pops up, the browser say its url is
>
> http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167
>
>
> Now with my code
>
> public class DownloadWebPage
> { public static void main (String[] args) throws IOException
> {
> URL url = new
> URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1");
> BufferedReader webRead = new BufferedReader(new
> InputStreamReader(url.openStream()));
> String line;
> while ((line = webRead.readLine()) != null)
> {
> System.out.println(line);
> }
>
> }
> }
>
> I can download the page at
>
> http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH
>
>
> But I cannot download the page at
>
> http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167
>
>
> That the javascript function
>
> "javascript:dt_pop('PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167',
> 'remote', 610, 550, 10, 10, 'no', 'yes', 'no', 'no'); "
>
>
> In the page
>
> http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH
>
> calls.
>
>
>
> When I try to download
>
> http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167
>
> With my code, all i get is
>
> <HTML><HEAD><SCRIPT
> LANGUAGE="JAVASCRIPT">location.replace("http://www.dreamteamfc.com");</SCRIPT></HEAD></HTML>
>
>
>
>
> So how do i go about downloading the contents of the html page that is
> in the window that is displayed when the javascript function above is
> called?
>
>
> regards,
>
> pat
>
> Chander <email***@***.com> wrote in message news:<7_o1d.6844$email***@***.com>...
>
>>Have you checked its behavious whenyou try opening on Browser..? it
>>redirects you to someother page and checks if you are logged in.. etc etc..
>>
>>The way you are doing is not the proper way you have to follow the RFC
>>for HTTP1.1 for the same... the procedure used by you might work for
>>some sites but not for all the sites....
>>
>>Cheers
>>
>>http://www.ziksa.net
>>email: email***@***.com
>>
>>Patrick wrote:
>>
>>>I am trying to download the html page at
>>>
>>> http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1
>>>
>>>Using the code
>>>
>>> public class DownloadWebPage
>>> { public static void main (String[] args) throws IOException
>>> {
>>> URL url = new
>>>URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1");
>>> BufferedReader webRead = new BufferedReader(new
>>>InputStreamReader(url.openStream()));
>>> String line;
>>> while ((line = webRead.readLine()) != null)
>>> {
>>> System.out.println(line);
>>> }
>>>
>>> }
>>> }
>>>
>>>But all I am getting is
>>>
>>>
>>> <HTML><HEAD><SCRIPT
>>>LANGUAGE="JAVASCRIPT">location.replace("http://www.dreamteamfc.com");</SCRIPT></HEAD></HTML>
>>>
>>>
>>>I'm guessing that when the web brower meets this code it executes the
>>>javascript
>>>
>>>
>>> location.replace("http://www.dreamteamfc.com")
>>>
>>>
>>>And somehow loads the web page.
>>>
>>>
>>>How do I go about downloading the actual web page that gets displayed
>>>in a normal web browser.
>>>
>>>
>>>
>>>
>>>Any help appeciated!
>>>
>>>
>>>pat
|
| |
|
| |
 |
googleaddress

|
Posted: 2004-9-15 22:38:00 |
Top |
java-programmer >> Download a webpage that contains javascript
Ok, I am starting to understand what is going on now a little better.
I noticed that when I access
http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH
The server sends a cookie. And then when I access
http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167
I get the table of players and their respective points.
I used the following code
public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167");
URLConnection uc = url.openConnection();
System.out.println(uc.getHeaderField("Set-Cookie"));
}
To get the cookie, which was
CF_HA=2415676698; Domain=.dreamteamfc.com; expires=Tue, 14-Sep-04
22:25:46 GMT; Path=/
I think
CF_HA, is just a unique identifier, a variable which in incremented
by the server for each new client
Domain, is just the domain
expires, is just the expiry date
Path, hmm dunno
Now I hardcoded the cookie into the code, with a valid expiry date
public static void main (String[] args) throws IOException
{
URL url = new
URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167");
URLConnection uc = url.openConnection();
String cookie = "CF_HA=2415676698; Domain=.dreamteamfc.com;
expires=Tue, 14-Sep-04 22:25:46 GMT; Path=/";
uc.setRequestProperty("cookie",cookie);
int i = 0;
while ((i = uc.getInputStream().read()) != -1)
{ System.out.print((char) i);
}
}
Now, when I run this code I get the following error
Exception in thread "main" java.io.IOException: Server returned HTTP
response code: 400 for URL:
http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1133)
at Test.main(Test.java:46)
Is the following method
uc.setRequestProperty("cookie",cookie);
The correct way to send the cookie to the server?
Any pointers on what I should try next, I'm not quite sure where to
look.
pat
Chander <email***@***.com> wrote in message news:<aKO1d.12626$email***@***.com>...
> As I menatined earlier read the rfc for http 1.1 when you are requesting
> a page firsdt you get is the header you get information for size of the
> data to follow, if server has responded as error, what type of error..
> or the page is to be redirected, etc.. as per these information you are
> to read the following lines or resend the request to the other page as
> direction in the header..
>
> Cheers
|
| |
|
| |
 |
Mark Marcus

|
Posted: 2004-9-21 10:36:00 |
Top |
java-programmer >> Download a webpage that contains javascript
On 15 Sep 2004 07:38:22 -0700, email***@***.com (Patrick)
wrote:
>Ok, I am starting to understand what is going on now a little better.
>
>
>I noticed that when I access
>
> http://www.dreamteamfc.com/dtfc04/servlet/OpenFSELogin?homename=dtfc04&language=ENGLISH
>
>The server sends a cookie. And then when I access
>
> http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167
>
>I get the table of players and their respective points.
>
>I used the following code
>
> public static void main (String[] args) throws IOException
> {
> URL url = new
>URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167");
> URLConnection uc = url.openConnection();
> System.out.println(uc.getHeaderField("Set-Cookie"));
> }
>
>
>To get the cookie, which was
>
> CF_HA=2415676698; Domain=.dreamteamfc.com; expires=Tue, 14-Sep-04
>22:25:46 GMT; Path=/
>
>I think
> CF_HA, is just a unique identifier, a variable which in incremented
>by the server for each new client
> Domain, is just the domain
> expires, is just the expiry date
> Path, hmm dunno
>
>Now I hardcoded the cookie into the code, with a valid expiry date
>
> public static void main (String[] args) throws IOException
> {
> URL url = new
>URL("http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167");
> URLConnection uc = url.openConnection();
>
> String cookie = "CF_HA=2415676698; Domain=.dreamteamfc.com;
>expires=Tue, 14-Sep-04 22:25:46 GMT; Path=/";
> uc.setRequestProperty("cookie",cookie);
> int i = 0;
>
> while ((i = uc.getInputStream().read()) != -1)
> { System.out.print((char) i);
> }
> }
>
>
>Now, when I run this code I get the following error
>
>
>Exception in thread "main" java.io.IOException: Server returned HTTP
>response code: 400 for URL:
>http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1&title=GOALKEEPERS&gameid=167
> at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1133)
> at Test.main(Test.java:46)
>
>
>Is the following method
>
> uc.setRequestProperty("cookie",cookie);
>
>The correct way to send the cookie to the server?
>
>
>Any pointers on what I should try next, I'm not quite sure where to
>look.
>
>
>pat
>
>Chander <email***@***.com> wrote in message news:<aKO1d.12626$email***@***.com>...
>> As I menatined earlier read the rfc for http 1.1 when you are requesting
>> a page firsdt you get is the header you get information for size of the
>> data to follow, if server has responded as error, what type of error..
>> or the page is to be redirected, etc.. as per these information you are
>> to read the following lines or resend the request to the other page as
>> direction in the header..
>>
>> Cheers
Well, I agree with Chander that you need to read the RFC on HTTP 1.1
(RFC 2068) which can be found at
http://www.ietf.org/rfc/rfc2068.txt?number=2068. I'd give you more
detailed advice, but I think a lot of it would be speculation (my
programmer friend is sitting next to me, so these are his words)
So here is the speculation. The issue that might be the cause of your
woes. In order for you to set properties in a URLConnection, the
properties MUST be set before you call getInputStream() or getHeader()
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- How to receive events from a jcombobox in an internal Jpanel ??Good evening,
I've a Frame with two Jpanel, in Jpanel1 I've a Jcombobox and it's
listener while in Jpanel2 I've a JLabel where I want to write the
selected value of the Jcombobox,
Jpanel1 , Jpanel2 and the main frame are in 3 separate class and files,
this because I want to arrange a modular design.
My question is how I can receive in the main Frame the event coming
from Jcombox value changed in Jpanel1 ???
Thanks for your help
Antonio
www.etantonio.it/en
- 2
- Vetoing a change by DefaultCellEditor in JTableI'm using a DefaultCellEditor with a JTextField to capture a String
that is ultimately passed to setValueAt in my TableModel. In that
method, I have logic which could throw an exception if the String's
contents proves to be invalid (i.e. one use is where the String is a
regular expression that might be syntactically invalid).
How can I handle this? Right now, the code throws an Exception which
I'd like to catch, display a dialog, and then return the user to
editing without ever committing the value. Is this easily doable?
Regards,
Brian.
- 3
- Help needed (GUI/passing objects)
Hi, I'm a student learning java. In my latest assignment, I am to create a
Scheduler/Diary, with a GUI.
I am getting the error
Exception in thread "main" java.lang.NoSuchMethodError: BaseFrame: method
<init>
()V not found
at Dairy.main(Dairy.java:22)
From the main method in 'project.class', I create the diary object, which
creates month and day objects etc...
I create a state object, which takes in the Diary Object and points to the
selected month, day, appointment etc
I then create a gui object, which is to change the state (through methods in
the state).
This error occurs whenever I pass in the state object to the GUI
('BaseFrame').
Exception in thread "main" java.lang.NoSuchMethodError: BaseFrame: method
<init>
()V not found
at Dairy.main(Dairy.java:22)
I'm not sure whats causing this. I'm checking like 22 in the 'diary' class,
but it's a }. Not too helpful.
GUI appears when no state object is passed, can't manipulate the data with
that though....
In main:
------------
//set up the Diary
Diary dia = new Diary();
//set up the state
State diaryState = new State(dia);
//Set up the gui
BaseFrame firstFrame = new BaseFrame(diaryState);
---------------
When setting up the GUI:
---------------
State curState;
//constructor for the basic frame, takes in a state object
public BaseFrame(State sta)
{
curState = sta;
.....................}
--------------------------
Done a search online, didn't get too far. Any ideas? What does that error
mean exactly?
- 4
- src.zip of j2ee1.4 sdkHi,
I downloaded the j2ee1.4 sdk, but I can't seem to find the source files
in that package. They used to be in a src.zip file, or not? Anyway I
already looked at the Sun website, but I didn't find a URL to download
the source files from.
Kind regards,
Dirk
- 5
- Any HID support for Java?Human Interface Device (mouse, etc)
Does anyone know whether java support the HID devices? (under MS
Windows)
I checked the document but did not see any. A google on this group
also returns little information.
Thanks a lot.
- 6
- Precision problem with doubleHi everyone,
I am a Java beginner, and I am trying to create a very simple binary
tree.
Each node has a value, the left child has the same value + an
increment, the right child has the same value - the same increment.
I try to recursively create the tree, but I have precision problems.
My "main" node has a value of 10, the increment is 0.1, tree depth is
4
So i want a tree that goes like this :
depth 1 : 10
depth 2 : 0.9 / 10.1
depth 3 : 0.8 / 10 / 10 / 10.2
depth 4 : 0.7 / 0.9 / 0.9 / 10.1 / 0.9 / 10.1 / 10.1 / 10.3
But at depth 4 when I try to print the value I get 9.700000000000001
instead of 9.7, and 10.299999999999999 instead of 10.3
And things get worse when the depth increase.
All the values and increment are stored in double (native type).
Is it normal? How can I avoid this problem?
Thanks a lot,
Tom.
[main class]
double increment = 0.1;
double startValue = 10;
int maxDepth = 4;
Tree myTree = new Tree(startValue, 1);
myTree.recursivelyCreateChildren(increment, maxDepth);
[Tree.java]
public int depth;
public double value;
public Tree leftChild;
public Tree rightChild;
Tree(double value, int depth){
this.value=value;
this.depth=depth;
System.out.println("node of depth " + depth + " created, value = " +
value);
}
public void createChildren(double increment){
rightChild = new Tree(value - increment, depth+1);
leftChild = new Tree(value + increment, depth+1);
}
public void recursivelyCreateChildren(double increment, int maxDepth)
{
if (depth < maxDepth){
createChildren(increment);
leftChild.recursivelyCreateChildren(increment, maxDepth);
rightChild.recursivelyCreateChildren(increment, maxDepth);
}
}
- 7
- PrintServiceLookup.lookupPrintServices fails to list new printers until re-start (JDK1.4.2_03, Linux RedHat, Tomcat 4.x)Hi Forum,
How could I get
javax.print.PrintServiceLookup.lookupPrintServices(null,null) to return the
current available services while the program that uses lookupPrintServices
is running? In a tomcat servlet I use the lookupPrintServices(..) to get a
list of the printer services available. The class works well and returns the
list but if I install a new printer, the servlet does not list the newly
installed service until I restart Tomcat. Is there a way to unload and
reload the PrintServiceLookup class and then call
PrintServiceLookup.lookupPrintServices?
It appears that the lookupPrintServices(..) returns the list of services
that was available when the instance of the virtual machine was started.
Hence, while the instance is running, it allways returns the same list of
services. If I run a program that lists the services and then exits, the
program lists the newly added printer on re-run. But if the program never
exits (it runs in a loop, re-listing the services every so often), and I add
a new printer while the program is running, the newly added printer is not
listed until I terminate teh rpogram and re-start it.
Thanks in advance for your responser
- 8
- 9
- Reference and Garbage CollectionI'm not quite sure about what kind of references to an object determine
its "alive" quality and its readiness for garbage collection. For the
moment I understand that *any* living reference, including non-explict
of member classes, keep the object alive.
Would you agree that the follwoing class "NeverRelease" entails
instances which will never get prone to garbage collection?
class NeverRelease
{
Child1 child;
public NeverRelease ()
{
child = new Child1();
}
private class Child1
{
}
}
While would you also agree that instances of the following class
"AlwaysRelease" always become garbage because the member class is static
and hence does not take reference to the enclosing class?
class AlwaysRelease
{
Child2 child;
public AlwaysRelease ()
{
child = new Child2();
}
private static class Child2
{
}
}
- 10
- JComboBox strange behaviorHello!
I have interesting problem with javax.swing.JComboBox (java 1.4.2)
When I click at combo to open list - there is no reaction to mouse
moves except these on combo header or outside my combo. So I cannot
choose any item from the list.
But I can use keyboard...
This is default combo, I've just create it and populate some Strings
into it.
any idea what's wrong?
B.
- 11
- 12
- JNI: passing Objects containing non-primitive types back and forthHi folks,
looked through a lot a threads overhere already but did not find an
answer detailed enough:
I want to map a c-structure like this created in my native code
struct mystruct {
long pid ;
long data[] ;
long meta[][] ;
} ;
to a java-object within my Java-code which would look like this IMHO:
public class ComplexData {
final int maxdata = 100 ;
final int maxmeta = 5 ;
private long pid ;
private data[] = new long[maxdata] ;
private meta[][] = new long[maxdata][maxmeta] ;
public void ComplexData() {
// Assigning values
pid = 1234 ;
data[0] = ...
}...
As far as I understood it is now possible to pass this Java-object to
the native code using the JNI-Function NewObject and read the members
and assign their values to the c-structure's members (to make them
available from within c) and the other way round, assign the values
from the c-structure to the members within the Java-object (possibly
without the initialization in the "Java-world" (I need both
directions).
My problem now is: How do I access the object's members (especially
the array types) from within c? Functions pointed to in different
threads (e.g. (Get|Set)LongArrayRegion ) need the reference to the
array, but I have only the reference to the object up to now.
Any code snippets based on the code above would be helpful.
Cheers
Bernd
- 13
- performance and memory usage.
Hi
I created a test program to try the speed and size management of the JDK
HashMap. With regards to this I was wondering if anybody has any
comments on whether this is an appropriate way of testing this
performance, i.e. how realistic is the results with respect to caching
influence of data, heap management etc. The code is simple, but would it
produce a correct result. (the program finishes in 11 seconds on my
machine). the code is attached.
Secondly, I was wondering about the memory (heap) usage in java for this
program. It needs at least 256 MB of heap to run to finish. cmd:
java -Xms32m -Xmx256m -cp target/classes/ App
Using -Xmx128m causes OutOfMemoryError.
When calculating on the size of the datastructure i find approx that
2M Dto's = 16MB
2M Integer's for map key = 8MB
2M Integer's for ArrayList = 8MB
Thats a total of 32MB plus some megabytes for the objects,
datastructures, JVM and so on. So probably about 48-64MB in total.
Thats a completely different number from 128 MB or 256 MB.
Does anybody have any comments on why the program requires that much memory?
arnie
*****************
/* Create 2 million Dto objects with random data and insert into HashMap
also add key to an iterable list */
public void test1() {
int size = 2000000;
Map<Integer, Dto> hmap = new HashMap<Integer, Dto> (size);
Collection<Integer> alist = new ArrayList<Integer> (size);
Random r = new Random();
Dto data;
for (int c=size; c>0; c--) {
data = new Dto();
data.ip= r.nextInt(2000000000);
hmap.put(data.ip, data);
alist.add(data.ip);
}
int c = 1;
for (Integer d : alist) {
hmap.get(d);
}
}
/* Simple data placeholder */
public class Dto
{
public int ip;
public int serialnum;
}
- 14
- Java encryption <--> .NET encryptionHajo,
I need to exchange encypted data between
.NET and Java environments. The first
problem I encountered is that symmetric
ciphers in .NET needs initialization
vector and Java counterparts don't.
Can some one point me out the place
where I can find any practise and
patterns for encrypted communication
between Java and .NET ?
thanks for any info
Gawel
- 15
- Java FACT ?"FACT: Java has no first-class functions and no macros. This results in
warped code that hacks around the problem, and as the code base grows,
it takes on a definite, ugly shape, one that's utterly unique to Java.
Lisp people can see this clear as day. So can Python folks, so can Ruby
folks. Java people flip out, and say "macros are too much power",
or "what do u mean i dont understand u" or "fuck you, you jerk,
Lisp will NEVER win". -- Steve Yegge, 2006-04-15
what would you people make of the above statement ? Has anyone here
used Lisp *and* Java on major projects ? If so would you say this
sounds off-base or correct ?
thanks,
--dcnstrct
|
|
|