comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* LINUX: Swing creates - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6fe177e70bb39950
* Servlet container not recognizing WEB-INF - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b567c4f60db968d9
* java static factory method vs. constructor - object reuse - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c9c44eab569d8444
* Static mess - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f0afc75c5b4e5d21
* A HTTP server question - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1ed9ac9e989861f8
* byte to long: convertion problem - 5 messages, 5 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b121052e661ad459
* Socket problem in applet - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/469e9f779424c7fa
* Sort Array Problem - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc8b01c6cee7f666
* Improving website responsiveness. - 6 messages, 5 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f719ebe188f50463
* Equivalent to C's #line directive? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5cce873502ce5827
* Attn: Technical Industry Candidates (MAKE $1000) - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1e08fa4fba7f42d7
* Fast TIFF reading library - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/62560e8e5fe54c9e
* writeObject and readObject problem - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e6fc9480a3a7f42a
* Is it possible to alter Ant properties after they've been initialized? - 1 messages, 
1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b49e18141bedfe87
* Socket problem -- response slow for host with domain (on SunOS 5.8) - 1 messages, 1 
author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bfb84c34caf0c9e9
  
==========================================================================
TOPIC: LINUX: Swing creates
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6fe177e70bb39950
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 8:11 am
From: [EMAIL PROTECTED] (tom baker) 

Paul Lutus <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> tom baker wrote:
> 
> > Hi there,
> > 
> > I'm programming an application for touchscreens. Each 'page' on the
> > screen is a JFrame. Among other criterions it's IMHO the easiest way
> > to go into 'idle'-state  (by using a javax-Timer with 'dispose').
> > 
> > Each new JFrame (e.g. ttt= new gui_menu_one(); ) creates a new linux
> > thread (or process). But after dispose() the thread/process of this
> > JFrame is still there.
> 
> You need to post your code, not a series of comments where your code would
> have been had you posted it.
> 
> > Now I worry about that the whole system could 
> > slow down or stop after a certain time, because the OS still has to
> > provide ressources for these non-active processes/threads.
> > 
> > What is the cause?  java?
> 
> It's definitely your code. The code you didn't post.
I see ;-)


I hope this is part of my code ist not to short but meaningful enough:


public class cls_gui_start extends JFrame
{

    private cls_gui_start_swt_log     gui_start_swt_log_inst;
    private GuiStartListener          listener_gui_start;
    ...


    public cls_gui_start()
    {
        JTextField jtf_code;
        JButtons, etc.
    }

    class GuiStartListener implements ActionListener {


        public void actionPerformed(ActionEvent event)
        {

            // 
----------------------------------------------------------------------------

            if (  (jtf_code.getText()).startsWith("P") )
            {

                gui_start_swt_log_inst=new
cls_gui_start_swt_log(getCode());
                gui_start_swt_log_inst.show();

                gui_start_swt_log_inst.addWindowListener(new
WindowAdapter() {
                    public void windowClosed(WindowEvent event)
                    {
                        System.out.println("gui_start: the end of
gui_start_swt_log_inst");
                    }
                });
            }
        }
    }
}


##########################################################
##########################################################
//
// Staff Work time logging


public class cls_gui_start_swt_log extends JFrame
{

    private GuiStartSwtLogListener listener_gui_start_swt_log;
    private javax.swing.Timer countdown;
    ...

    public cls_gui_start_swt_log(int code)
    {
        // Kills the window after 10 seconds if it is unused
        countdown = new javax.swing.Timer(10000, new ActionListener()
{
            public void actionPerformed(ActionEvent e) {
                countdown.stop();
                dispose();
            }
        });
        countdown.start();

        // Buttons etc.
    }


    class GuiStartSwtLogListener implements ActionListener {


    public void actionPerformed(ActionEvent event)
    {

        // ------------------------------------------------------------------------

        if (event.getSource() == btn_begin)
        {
            countdown.stop();
            // write into file
            dispose();
        }
    }
}




Thanks in advance !

tom




==========================================================================
TOPIC: Servlet container not recognizing WEB-INF
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b567c4f60db968d9
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 8:35 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

Servlet container not recognizing WEB-INF - * Solved * 

On Sat, 07 Aug 2004 01:28:32 -0400, Sudsy wrote:
...
> Drop me a note off-line and let's see if we can get this squared
> away ..

Thanks Sudsy, you saved the day on this one!

> .. and you can post the ultimate solution back here.

Our communications quickly narrowed it down to the 
server.xml, which Sudsy immediately recognised was faulty. 

The Context element was missing the 'appBase' attribute..  
Exactly how it became missing in the first place remains a mystery.

The fix was quickly forthcoming, but it took a long
time to communicate the corrected file back through the 
(rather long) lines of communication.

The server is now up and running, and I can continue
with the installation and testing that has languished 
for over a month now.  ( Yay! )

Thanks also, to William and Tony for their responses.

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.lensescapes.com/  Images that escape the mundane




==========================================================================
TOPIC: java static factory method vs. constructor - object reuse
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c9c44eab569d8444
==========================================================================

== 1 of 3 ==
Date:   Tues,   Sep 21 2004 8:36 am
From: "VisionSet" <[EMAIL PROTECTED]> 


"Joona I Palaste" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> javaguy44 <[EMAIL PROTECTED]> scribbled the following:

>
> > class Foo
> > {
> >   private Foo() {}
>
> >   public static Foo getInstance() {
> >     return new Foo()
> >   }
> > }

>
> An object of Foo is not being reused. The code above is obviously only
> an example of what might be done. As it stands, it offers no benefit
> whatsoever over a public constructor. But it could be expanded into
> either a Singleton or a Factory.

I think it is worth pointing out that as it stands it actually offers a huge
benefit over a public constructor, namely that it has the potential to
supply an object of Foo OR ANY SUBCLASS. It is therefore much more flexible
and means that modification to the initial instance can be done in one place
from a maintenance point of view.
When you extend this pattern to return an interface type you gain even more
flexibility.  Obviously this is not a reason to plaster the pattern
everywhere, but when these are potential requirements it should be
considered, it is therefore a widely used pattern, after Adapter, perhaps
the most common.

--
Mike W





== 2 of 3 ==
Date:   Tues,   Sep 21 2004 11:45 am
From: [EMAIL PROTECTED] (javaguy44) 

Hi Joona,

Have you read Effective Java?  I think you are just reconfirming my
question, because unless you misunderstood me, as far as I see, an
object of Foo is not being reused.  But unless I misinterpreted, Mr.
Bloch says that object's do cache when using static factory methods. 
I just don't know how.

I know about Singleton and returning a different subclass within the
static factory...I'm mainly wondering about object reuse and caching

Thanks for your reply



Joona I Palaste <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> javaguy44 <[EMAIL PROTECTED]> scribbled the following:
> > Hi,
>  
> > I'm just picked up Bloch's Effective Java and had a question about the
> > reuse of objects when using a static factory method.
>  
> > Take the following:
>  
> > class Foo
> > {
> >   private Foo() {}
>  
> >   public static Foo getInstance() {
> >     return new Foo()
> >   }
> > }
>  
> > How is an object of Foo being reused?  All I see is that every time
> > static getInstance is called, it returns a new Foo object.  What am I
> > not seeing?  Am I missing something underneath the hood that the JVM
> > is checking?
> 
> An object of Foo is not being reused. The code above is obviously only
> an example of what might be done. As it stands, it offers no benefit
> whatsoever over a public constructor. But it could be expanded into
> either a Singleton or a Factory.
> For a Singleton, getInstance() should reuse the same Foo object. For a
> Factory, it should do something with the Foo it creates, or have the
> opportunity to return a subclass of Foo.
> 
> > One more question - can only immutable class objects be reused?
> 
> No, there is no such restriction. Reuse any class you want to.



== 3 of 3 ==
Date:   Tues,   Sep 21 2004 12:09 pm
From: Joona I Palaste <[EMAIL PROTECTED]> 

javaguy44 <[EMAIL PROTECTED]> scribbled the following:
> Hi Joona,

> Have you read Effective Java?  I think you are just reconfirming my
> question, because unless you misunderstood me, as far as I see, an
> object of Foo is not being reused.  But unless I misinterpreted, Mr.
> Bloch says that object's do cache when using static factory methods. 
> I just don't know how.

Like I said, in the exact code you posted, no Foo object is ever
getting reused. Using a static factory method does not, by itself,
make objects be reused.

> I know about Singleton and returning a different subclass within the
> static factory...I'm mainly wondering about object reuse and caching

If you already know about Singleton, then you should already know how
to reuse an object in the static factory method.

> Thanks for your reply

> Joona I Palaste <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
>> javaguy44 <[EMAIL PROTECTED]> scribbled the following:
>> > Hi,
>>  
>> > I'm just picked up Bloch's Effective Java and had a question about the
>> > reuse of objects when using a static factory method.
>>  
>> > Take the following:
>>  
>> > class Foo
>> > {
>> >   private Foo() {}
>>  
>> >   public static Foo getInstance() {
>> >     return new Foo()
>> >   }
>> > }
>>  
>> > How is an object of Foo being reused?  All I see is that every time
>> > static getInstance is called, it returns a new Foo object.  What am I
>> > not seeing?  Am I missing something underneath the hood that the JVM
>> > is checking?
>> 
>> An object of Foo is not being reused. The code above is obviously only
>> an example of what might be done. As it stands, it offers no benefit
>> whatsoever over a public constructor. But it could be expanded into
>> either a Singleton or a Factory.
>> For a Singleton, getInstance() should reuse the same Foo object. For a
>> Factory, it should do something with the Foo it creates, or have the
>> opportunity to return a subclass of Foo.
>> 
>> > One more question - can only immutable class objects be reused?
>> 
>> No, there is no such restriction. Reuse any class you want to.

-- 
/-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"How can we possibly use sex to get what we want? Sex IS what we want."
   - Dr. Frasier Crane




==========================================================================
TOPIC: Static mess
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f0afc75c5b4e5d21
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 8:42 am
From: "Mike Schilling" <[EMAIL PROTECTED]> 


"Thomas G. Marshall" <[EMAIL PROTECTED]> 
wrote in message news:[EMAIL PROTECTED]
> Mike Schilling coughed up:
>> "Razvan" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>>> Hi !
>>>
>>>
>>>
>>>
>>> In the following code:
>>>
>>> public class CDummy
>>> {
>>> static {
>>> jj = 5;
>>> // System.out.println("jj=" + jj);
>>> }
>>>
>>> public static void main(String args[])
>>> {
>>> System.out.println("CDummy.");
>>>
>>> System.out.println("jj = " + jj);
>>> }
>>>
>>> static int jj = 6;
>>> }
>>>
>>> I can assign to the primitive jj the value 5 even if the primitive is
>>> defined later, however I cannot print its value because I use a
>>> 'forward reference' ! Can somebody explain why I can do
>>>
>>>
>>> jj = 5;
>>>
>>>
>>> but I cannot do
>>>
>>> System.out.println("jj=" + jj);
>>>
>>>
>>> I think that I should either have access to jj prior to declaration +
>>> definition (line: static int jj = 6;) in both cases or the access
>>> should be denied in both cases. If there is a logical explanation for
>>> this I would like to hear it.
>>
>> I don't know what you mean by "can't do it".  It compiles and runs
>> fine (under 1.4.2).
>
>
> HUH?  Are you sure?  My 1.5.0 is gacking on it big time, as is consistent
> with the jls, IMO anyway.
>
> Did you remove the // in front of his erring line?
>

No, I didn't realize that was his problem.  That fails, of course, for the 
reasons iamfractal explains. 






==========================================================================
TOPIC: A HTTP server question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1ed9ac9e989861f8
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 8:46 am
From: Joe <[EMAIL PROTECTED]> 

In article <[EMAIL PROTECTED]>, s917124
@mail.yzu.edu.tw says...
>  when java programs is running,indicate that(I do mark at the java program)
> (1)HTTP server do receive nokia 6600's HTTP request.
> (2)HTTP response headers is sent to the client.
> (3)the XHTML file is sent to the client.
> 
> but nokia 6600 cannot browse the XHTML file.
> could someone excellent to give me a constructive suggestion?
> thank you
> 


It sounds like the Nokia browser can't parse what you are sending it. 
You might try to confirm this by sending a very simple, standardized 
file:
<html><body>Hello World</body></html>

In any event, from what you've said, I don't think the problem lies with 
java or your server.




==========================================================================
TOPIC: byte to long: convertion problem
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b121052e661ad459
==========================================================================

== 1 of 5 ==
Date:   Tues,   Sep 21 2004 8:54 am
From: "andreas" <[EMAIL PROTECTED]> 

>I want translate 8 byte to a long.
>But  I am a problem.

this is, of course, not an easy basis to start with... :-)

andreas





== 2 of 5 ==
Date:   Tues,   Sep 21 2004 9:21 am
From: "Thomas G. Marshall" <[EMAIL PROTECTED]> 

andreas coughed up:
>> I want translate 8 byte to a long.
>> But  I am a problem.
>
> this is, of course, not an easy basis to start with... :-)
>
> andreas

:)  But the usenet is fully global.  English is a 2nd (or 3rd) language for
many of its perusers.

I try to automatically slack cut ( anguished english idiom :) ) in this
regard.


-- 
"Well, ain't this place a geographical oddity!
Two weeks from everywhere!"





== 3 of 5 ==
Date:   Tues,   Sep 21 2004 9:40 am
From: Jonck <[EMAIL PROTECTED]> 

In <[EMAIL PROTECTED]> andreas wrote:
>>I want translate 8 byte to a long.
>>But  I am a problem.
> 
> this is, of course, not an easy basis to start with... :-)

LOL :-D



== 4 of 5 ==
Date:   Tues,   Sep 21 2004 11:03 am
From: John Davison <[EMAIL PROTECTED]> 

cccc wrote:
> Hi,
> 
> I want translate 8 byte to a long.
> But  I am a problem.
> 
> The source code that I am using is:
> 
> char[] data={0x3f, 0xe7, 0x5d, 0x40, 0x5f, 0x50, 0xcc, 0x33};
> 
> long as =
> (0xFF & data[0]) << 56 |
> (0xFF & data[1]) << 48 |
> (0xFF & data[2]) << 40 |
> (0xFF & data[3]) << 32 |
> (0xFF & data[4]) << 24 |
> (0xFF & data[5]) << 16 |
> (0xFF & data[6]) << 8 |
> (0xFF & data[7]);
> 
> System.out.println("BIN="+Long.toBinaryString(as));
> System.out.println("HEX="+Long.toHexString(as));
> 
> Why first print show 32 bit instead of 64?
> Why second print show a hexadecimal value  different to array?
> 
> You can help me?
> 
> Ciao,
> CC
> 
> 

Get the source code to the Java Standard Library and look at
java/io/Bits.java

This is what the classes use to convert primary types into streams of 
bytes, and vice versa.

- john



== 5 of 5 ==
Date:   Tues,   Sep 21 2004 11:37 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Tue, 21 Sep 2004 14:03:46 -0400, John Davison wrote:

> Get the source code to the Java Standard Library and look at
> java/io/Bits.java

Even closer, a mere two clicks away..
<http://www.physci.org/source.jsp?class=java.io.Bits>

HTH

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.lensescapes.com/  Images that escape the mundane




==========================================================================
TOPIC: Socket problem in applet
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/469e9f779424c7fa
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 9:08 am
From: "VK" <[EMAIL PROTECTED]> 

It's a clear VM cache issue here.

2 options:
1) to stay with the docked applet (on the html page), you have to fill the
stop() and specially finalize() applet methods to handle/close/close threads
nicely.
2) un-dock the applet in separate frame, and pop it up by a small inline
"starter" applet.


Faced quod potui, faciant meliora potentes...






==========================================================================
TOPIC: Sort Array Problem
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc8b01c6cee7f666
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 9:16 am
From: "Thomas G. Marshall" <[EMAIL PROTECTED]> 

Jim Cochrane coughed up:
> In article <[EMAIL PROTECTED]>, ak wrote:
>>>>> I posted too concisely for the trolls. I meant to say, apropos
>>>>> the OP's goal of learning Comparator:
>>>> who posts concisely wrong answers is the biggest troll.
>>>
>>> Among other traits, trolls can't bring themselves to post topically.
>>> Consider this behavioral breakthrough.
>> Consider to post answers only if you want to help
>>
>
> Have you two entered a contest with each other to see who can end up
> in the largest number of kill files?  If so, I'd say you're about
> even, so far.

I had to go into groups.google.com to see whom you were talking about, since
one of them is a near-permanent denizen of my bozo-bin, and there were no
attributions in the reply bodies.

Based upon the content I guessed correctly, and I'd be really surprised if
the readers of this ng don't all agree upon who is /far/ more plonked.

-- 
"Well, ain't this place a geographical oddity!
Two weeks from everywhere!"






==========================================================================
TOPIC: Improving website responsiveness.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f719ebe188f50463
==========================================================================

== 1 of 6 ==
Date:   Tues,   Sep 21 2004 9:27 am
From: Rico <[EMAIL PROTECTED]> 

We have this JSP-based site whose code I've seen and I came across those
gems that would query a database and store all relevant results into
Vector's. But for each result in one given Vector the guy chose to make
one corresponding query to the db to get e.g the corresponding path.

The site feels horribly slow and I thought that the above was the cause
since it's so highly inefficient. So I set to task to store this table
from which we tap corresponding paths for each document in a Hashtable
first and then just loop through the document ID's to extract the matching
Hashtable values.

I was all excited about how much gain it would bring and pictured the
site to be a lot more slick... I was disappointed... I notice hardly any
difference :-(

Was that to be expected?
Could it be that what they tell us about how costly db connections are is
exaggerated? Or is the "optimization" I tried to make, thinking it's
actually the 'normal' way it should have been done, not much of an
optimization? :(

Rico.



== 2 of 6 ==
Date:   Tues,   Sep 21 2004 9:48 am
From: "Will Hartung" <[EMAIL PROTECTED]> 

"Rico" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> The site feels horribly slow and I thought that the above was the cause
> since it's so highly inefficient. So I set to task to store this table
> from which we tap corresponding paths for each document in a Hashtable
> first and then just loop through the document ID's to extract the matching
> Hashtable values.
>
> I was all excited about how much gain it would bring and pictured the
> site to be a lot more slick... I was disappointed... I notice hardly any
> difference :-(
>
> Was that to be expected?

What is shows is what happens when you try to fix a performance problem
without actually knowing what the performance problem is besides "it's
slow". This goes back to the sin of early optimization, which is basically
the same issue.

You need to step back and perform some analysis to get a better idea of
what's really slowing your site down. To quote Apollo 13: "Work the problem.
Don't make it worse by guessing!"

Even if you wrap some of your slow pages with a "System.out.println((new
java.util.Date()).getTime());" will tell you how much time is actually spent
within the page and not within the container or on the network.

It's a crude, but effective tool to give you a better idea where things are
slow in your code.

Regards,

Will Hartung
([EMAIL PROTECTED])






== 3 of 6 ==
Date:   Tues,   Sep 21 2004 10:04 am
From: Rico <[EMAIL PROTECTED]> 

All right. The post proper is:

Would this:
        for x=1 to 3000
                select * from table where item = 'x'

be a lot slower than:
        write result of (select * from table) into Hashtable
        for x=1 to 3000
                hashtable.get(x)
                
The answer, after I took a break: Hell Yes!!

        I timed it: it's slower by a factor of 65 !
        A full solid minute compared to one second.
        Now, why is the site still so slow then? hummm...



Rico.




== 4 of 6 ==
Date:   Tues,   Sep 21 2004 10:54 am
From: Bryce <[EMAIL PROTECTED]> 

On Wed, 22 Sep 2004 01:04:11 +0800, Rico <[EMAIL PROTECTED]> wrote:

>All right. The post proper is:
>
>Would this:
>       for x=1 to 3000
>               select * from table where item = 'x'
>
>be a lot slower than:
>       write result of (select * from table) into Hashtable
>       for x=1 to 3000
>               hashtable.get(x)

Well.. Yea, because #1 above makes 3000 SQL queries, whereas #2 only
one. #2 is letting the Database do what it does best.
                
>The answer, after I took a break: Hell Yes!!
>
>       I timed it: it's slower by a factor of 65 !
>       A full solid minute compared to one second.
>       Now, why is the site still so slow then? hummm...
>
>
>
>Rico.


--
now with more cowbell



== 5 of 6 ==
Date:   Tues,   Sep 21 2004 11:11 am
From: kaeli <[EMAIL PROTECTED]> 

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
enlightened us with...
> All right. The post proper is:
> 
> Would this:
>       for x=1 to 3000
>               select * from table where item = 'x'
> 
> be a lot slower than:
>       write result of (select * from table) into Hashtable
>       for x=1 to 3000
>               hashtable.get(x)
>               
> The answer, after I took a break: Hell Yes!!
> 
>       I timed it: it's slower by a factor of 65 !
>       A full solid minute compared to one second.
>       Now, why is the site still so slow then? hummm...
> 

Plus, if you want to do things with the result and re-loop through results 
and whatnot, it's a much nicer and quicker way than doing the query over and 
over...
It also allows you do get the same field multiple times, which is not allowed 
by specs from a ResultSet. (You can do it in the sense that the compiler 
won't stop you, but it's unpredicatable and can fail utterly.)
It also allows you to pass the data around after the resultset or connection 
is closed, which for me is a great plus. I was losing tract of open 
connections.
It also allows you to implement a backwards/forwards "resultset", which some 
drivers or DBMS have some problems with.
I wrote my queries to be able to return hashes or resultsets as desired long 
ago for these reasons.

As to why the site is slow, it may be server settings. Test servers are set 
to check all the pages upon request to see if they've changed so they can be 
recompiled. The production server should NOT have this option turned on. It 
can slow things down a lot.

There are a lot of things that could be slowing it down. Maybe the JSP 
instantiates too many objects and the server doesn't have good memory 
management, meaning it has to write to disk a lot. It could be an issue in 
the time it takes to send a ton of data out from the server to the client.

Try these things:

View the source of one of the pages that was slow and copy/paste it into a 
new document (as is) and save it over to the server. Then request it. Does it 
take the same amount of time to get the static version as the JSP version? If 
so, this has nothing at all to do with java.

If the static version came fast, but the JSP was slow, start breaking down 
the JSP code into sections and testing them and see which sections are really 
taking a lot of time. Keep going to find the bottleneck.

HTH

-- 
--
~kaeli~
Practice safe eating - always use condiments.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace




== 6 of 6 ==
Date:   Tues,   Sep 21 2004 11:47 am
From: "John B. Matthews" <[EMAIL PROTECTED]> 

In article <[EMAIL PROTECTED]>,
 Rico <[EMAIL PROTECTED]> wrote:

> All right. The post proper is:
> 
> Would this:
>       for x=1 to 3000
>               select * from table where item = 'x'
> 
> be a lot slower than:
>       write result of (select * from table) into Hashtable
>       for x=1 to 3000
>               hashtable.get(x)
>               
> The answer, after I took a break: Hell Yes!!
> 
>       I timed it: it's slower by a factor of 65 !
>       A full solid minute compared to one second.
>       Now, why is the site still so slow then? hummm...
> 
> Rico.

Also, after adding the optimization, be sure to remove the old 
query! (Not that _I've_ ever forgotten:-)

-- 
John
----
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/




==========================================================================
TOPIC: Equivalent to C's #line directive?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5cce873502ce5827
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 9:26 am
From: Daniel Bonniot <[EMAIL PROTECTED]> 

>  JSR 45 only works for byte code, does it?

No, I definitely remember there are two ways to feed the numbers, one when you 
generate bytecode (SourceDebugExtension), one when you generate source Java code.

Daniel
--
The Nice programming language: http://nice.sf.net




==========================================================================
TOPIC: Attn: Technical Industry Candidates (MAKE $1000)
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1e08fa4fba7f42d7
==========================================================================

== 1 of 3 ==
Date:   Tues,   Sep 21 2004 10:14 am
From: [EMAIL PROTECTED] (HeadHunter) 

Here is the opportunity to start making some big cash!

Hi everyone my name is Josh Stomel. I am a technical recruiter here in
California. I have two offices, one in Northern California and another
in Southern California. I am looking to compensate whoever can assist
me.

Right now the Job market is picking up and I am looking for some help
from you.

If you are looking for a new opportunity or have any friends or family
with a technical background such as;
(Software Engineers, Product Managers, QA, SQL, Embedded,
Architectures, Mac
Design, Java, etc…) you may be in luck. 


Therefore, get out there, ask your friends, ask coworkers and see who
is looking for a new exciting opportunity.

Here is what you do; 

Please contact me with the newest resume in a word document and all of
their contact info. If my team places one of your friends or family
then I will compensate you $1000 after 30 days of their placement.

This is uncapped, so the more resumes you can find, the more potential
you have to make some big money.

I have plenty of Mid – Senior level positions available in the
Northern and Southern California region.

Here is my contact information:

Email: [EMAIL PROTECTED]
Phone: 650-261-0211
Fax:   650-261-1044



== 2 of 3 ==
Date:   Tues,   Sep 21 2004 11:06 am
From: "Mike Schilling" <[EMAIL PROTECTED]> 


"HeadHunter" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Here is the opportunity to start making some big cash!
>
> Hi everyone my name is Josh Stomel. I am a technical recruiter here in
> California. I have two offices, one in Northern California and another
> in Southern California. I am looking to compensate whoever can assist
> me.

Hi, Josh.  Are you too young to remember Cantor and Siegel?  If so, read 
this:

http://www.improb.com/personal/gorin/ethics/cands-netcom.html

Then you can apologize, go away, and never return. 





== 3 of 3 ==
Date:   Tues,   Sep 21 2004 11:27 am
From: Steve Sobol <[EMAIL PROTECTED]> 

Mike Schilling wrote:

> Hi, Josh.  Are you too young to remember Cantor and Siegel?  If so, read 
> this:
> 
> http://www.improb.com/personal/gorin/ethics/cands-netcom.html
> 
> Then you can apologize, go away, and never return. 

Are *job postings* themselves offtopic in comp.lang.java.*?

OK, Josh's "give me referrals" post is not appropriate. But I have responded to 
  a post in the recent past, to c.l.j.programmer, from someone who was looking 
to fill a job for his company.


-- 
JustThe.net Internet & New Media Services, http://JustThe.net/
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / [EMAIL PROTECTED]
PGP Key available from your friendly local key server (0xE3AE35ED)
Apple Valley, California     Nothing scares me anymore. I have three kids.




==========================================================================
TOPIC: Fast TIFF reading library
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/62560e8e5fe54c9e
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 10:19 am
From: [EMAIL PROTECTED] (michael) 

"Niels Dybdahl" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Which TIFF reading library do you recommend ?
> I need a fast library to read large TIFF files.
> 
> Thanks in advance
> Niels Dybdahl

try 
http://java.sun.com/products/java-media/jai/iio.html

Michael




==========================================================================
TOPIC: writeObject and readObject problem
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e6fc9480a3a7f42a
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 11:16 am
From: [EMAIL PROTECTED] (newton klea) 

from server you have to do exactly what you do on the client but
reverse the call sequences. eg:

ois = new ObjectInputStream(req.getInputStream());
Object o = ois.readObject();
// do something with your object o  and send back:
oos = new ObjectOutputStream(res.getOutputStream());
oos.writeObject(output);
oos.flush();

this example use http server req and res but you can use socket in
place.




==========================================================================
TOPIC: Is it possible to alter Ant properties after they've been initialized?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b49e18141bedfe87
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 11:16 am
From: "Mike Schilling" <[EMAIL PROTECTED]> 


"vturner" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> If I define an Ant property and assign it a value, is it possible to 
> change
> it later.

No; property values, once set, cannot be changed.  Attempts to do so will 
fail silently.  Where in a language like Java, one might write:

    int i = 5;         // set to default value
    if (unusualConditionIsTrue())
        i = 10;        // set to other value

In ant, you need to set the unusual value first, something like:

    <target name="setProp" if="unusual.condition">
        <property name="i" value="10"/>
    </target>

    <target name="usual" depends="setProp">
        <property name="i" value="5/>
    </target>

Note that the setting of "prop" to 5 will fail when "unusual.condition " is 
true, since "prop" will already have been set to 10. 






==========================================================================
TOPIC: Socket problem -- response slow for host with domain (on SunOS 5.8)
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bfb84c34caf0c9e9
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 21 2004 12:06 pm
From: Nishi Bhonsle <[EMAIL PROTECTED]> 


Hi:

I have a servlet application deployed in OC4J. One of the page of the application 
takes the value for a smtpServer entered by the user from the client(value is a 
string), checks whether the value is valid  in the following backend code --

try
{
//if you can open a socket on the smtp host at port 25, then it is a valid smtp host
Socket smtpSocket = new smtpSocket("smtpServerVal", 25);
...
...
}
catch(UnknownHostException uhe)
{
..
....
}
catch(IOException ioe)
{
...
...
}
where smtpServerVal is the value entered through the client UI(browser).

I noticed that when I pass
Socket smtpSocket = new smtpSocket("yahoo", 25);
I get the UnknownHostException immediately(response is quick) and the page returns.

But when I pass
Socket smtpSocket = new smtpSocket("yahoo.com", 25);
The response of IOException takes a rather long time.. i.e. the page takes almost 
after 30 secs or more to return.

I observe this slower response only when the backend code is run on a solaris 8 
machine, not on windows XP or 2000.
Is this a known issue? How can I resolve this if any?

Thanks, Nishi.





=======================================================================

You received this message because you are subscribed to the
Google Groups "comp.lang.java.programmer".  

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


=======================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to