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

Today's topics:

* JSP output string with HTML query - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/84285a470181b30e
* Newbee question Mobile software - 4 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f36a637b3fe577e4
* question about Object.clone - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/86e64c7b7efb3866
* How to use JTree with very large data? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/145516a872afaa18
* Compiler trick - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2992422eec9fe49
* Thread synchronization - 4 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/172837b7b0667fd1
* Questions regarding object translation using JNI - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/931888db697efafe
  
==========================================================================
TOPIC: JSP output string with HTML query
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/84285a470181b30e
==========================================================================

== 1 of 1 ==
Date:   Tues,   Sep 14 2004 11:08 pm
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Wed, 15 Sep 2004 05:26:49 GMT, Tony Morris wrote:

> "June Moore" <[EMAIL PROTECTED]> wrote in message...
..
>> e.g. String str = "<b><u>bold and underlined</u></b>";
>>
>> In JSP, I use <%=str%>
>>
>> Instead of displaying the HTML version of the string (with bold and
>> underlining of the text), the above string is displayed. Can you help?

I thought at first that 'the above string' 
meant you saw this (literally) in the final page..
'<b><u>bold and underlined</u></b>'...

> Your JSP is correct.
> I'm guessing you aren't running the code on a servlet container, but a web
> server.

..but Tony's comment made the penny drop.

If the 'bold/underlined' string appeared in an 
HTML page it would render as HTML, whereas the 
second JSP command '<%=str%>' would vanish completely.

But if your server is neither configured to run 
.jsp's, and does not send the content to the 
client as an HTML content type, you would see all 
the code of the original JSP as written by you.

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology




==========================================================================
TOPIC: Newbee question Mobile software
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f36a637b3fe577e4
==========================================================================

== 1 of 4 ==
Date:   Wed,   Sep 15 2004 9:09 am
From: "fm" <[EMAIL PROTECTED]> 

Hello
I am newbee, thanks for your help.
I installed JBuilder X Enterprise...
Made the tutorial for the Hello world Midiet, all works fine on my PC.
Installed the Mime Type on IIS 2000 server
Transfered the JAR & JAD on my website and made a push test to my Nokia 3200
Connecting thru GPRS, informations received, tryed to install.....and then,
my Nokia answer : "software not supported"....
Any suggestions ?
Thanks for your help
david





== 2 of 4 ==
Date:   Wed,   Sep 15 2004 12:35 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Wed, 15 Sep 2004 09:09:31 -0700, fm wrote:

> "software not supported"....

"multi-posting not supported..."
<http://www.physci.org/codes/javafaq.jsp#xpost>

> Any suggestions ?

See the answer you already got on the other group.
(..and please refrain from multi-posting)

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology



== 3 of 4 ==
Date:   Wed,   Sep 15 2004 12:53 am
From: [EMAIL PROTECTED] 

Andrew Thompson <[EMAIL PROTECTED]> wrote:

>> "software not supported"....
>
>"multi-posting not supported..."
><http://www.physci.org/codes/javafaq.jsp#xpost>
>
>> Any suggestions ?
>
>See the answer you already got on the other group.
>(..and please refrain from multi-posting)


Ok, this does it.  

*ploink*



== 4 of 4 ==
Date:   Wed,   Sep 15 2004 1:20 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Wed, 15 Sep 2004 09:53:46 +0200, [EMAIL PROTECTED] wrote:

> Ok, this does it.  
> 
> *ploink*

Did you mean 'plonk', perhaps?    ;-)

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology




==========================================================================
TOPIC: question about Object.clone
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/86e64c7b7efb3866
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 15 2004 1:12 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

Tony Morris wrote:

>>BTW, you can in fact change one aspect of classes (the visibility of
>>fields and methods) through reflection, which is something that would
>>be necessary here.
> 
> 
> Are you referring to java.lang.reflect.AccessibleObject#setAccessible ?

Yes.

> This doesn't change anything about the class.

Matter of definition. To me, the visibility of members is an important
property of a class, and overriding the visibility defined by the
class's author constitutes a significant change.




==========================================================================
TOPIC: How to use JTree with very large data?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/145516a872afaa18
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 15 2004 1:14 am
From: Rogan Dawes <[EMAIL PROTECTED]> 

Sorin Gherman wrote:

> Rogan Dawes wrote:
> 
>>Sorin Gherman wrote:
>>
>>
>>>Hi,
>>>I have the following problem: I have this large amount of data,
> 
> stored
> 
>>>internally in some custom data structures (hierarchical ones, given
>>>the nature of the data - I am using some custom, tree-like
> 
> structurs
> 
>>>for this).
>>>I have to show the different relations within this data using
> 
> several
> 
>>>JTrees - one per "viewpoint". (The good news is that I only have to
>>>show one type of view at a time.)
>>>
>>>The first implementation I came up with is just creating a tree
> 
> model
> 
>>>(using DefaultMutableTreeNodes) for each view, and displaying it
> 
> using
> 
>>>JTree.
>>>Problem: memory consumption is very high (due to the duplication of
>>>the tree structures in memory, and the fact that the user may
> 
> toggle
> 
>>>between views fast, thus trees are created and thrown away - again,
>>>memory is an issue so I cannot afford to store them).
>>>
>>>I read about the possibility to have my own internal data implement
>>>the TreeNode interface, and have the JTree uses the internal data
>>>directly - thus avoiding the creation of extra trees.
>>>Problem: the implementation gets very complicated very fast due to
> 
> the
> 
>>>different views. I can still live with that, but then I realized
> 
> that
> 
>>>due to TreeNode.getParent() method, I would still have to
> 
> duplicate,
> 
>>>in memory, for each view, at least the "parent" references. (This
> 
> is
> 
>>>due to the fact that most of the internal nodes in my data
> 
> structures
> 
>>>have different parents in different views...). Which means it
> 
> doesn't
> 
>>>save that much memory after all... (well, it still saves the child
>>>references and the node duplication).
>>>
>>>So I am wondering: is there any well-know "cure" for these type of
>>>problems?
>>>
>>>Thanks in advance,
>>>Sorin Gherman
>>
>>
>>
>>All the previous replies have suggested using a TreeModel, this is just 
>>a suggestion to derive your implementation of TreeModel from 
>>AbstractTreeModel 
>>(http://www.chka.de/swing/tree/AbstractTreeModel.java), which is a nice 
>>base implementation that you can derive from.
>>
>>http://www.chka.de/swing/tree/ has some nice explanations of various 
>>swing models.
>>
>>This link has some examples of working with trees and treemodels:
>>
>>http://java.sun.com/products/jfc/tsc/articles/jtree/
>>
>>I would not use the AbstractTreeModel that they provide, as it simply 
>>delegates to TreeModelSupport, which just seems klunky to me.
>>
>>Rogan
> 
> 
>       
>      
>      Thanks a lot everybody for your answers!
>      So, the consensus seems to be that the way to go in order to
> avoid data duplication is to implement TreeModel (either directly, or
> through one particular AbstractTreeModel implementation).
>      One problem I see with this is related to a feature request I
> didn't mention (just realized it's a problem after trying to implement
> TreeModel): the user is supposed to be able to sort the tree levels in
> any of the views (by different criteria, dependent on the node
> information).
>      Sorting the underlying data structures is a solution only for the
> "natural view" (the one that happen to match the data structure 1:1),
> but for a view that's dynamically generated (by skipping one
> hierarchical level, for instance) this is not an option.
>      Is it still possible to use the "implementing the TreeModel"
> solution and still support tree sorting (AND not use extra memory? I
> understand that I can make my TreeModel implementations for getChild
> and getChildIndex aware of the sort order required, but this either
> seems to  me to:
> 1. complicate the implementation a lot and make it slower (I would
> also have to implement my own sorting too, since the nodes of some
> tree levels are not together in the same collection in the underlying
> data structure)
> or
> 2. eat up memory, in case I store each tree level references in some
> collections and sort them
> 
>      Any thoughts on this one?
> 
>      Thanks in advance,
>      Sorin Gherman

Hi Sorin,

In that case, you would probably want to use an "adapter pattern" to 
perform the sorting for you.

For an article discussing this technique, see 
http://www-106.ibm.com/developerworks/java/library/j-filters/

You would obviously want to do this for a TreeModel, not a ListModel, 
but the principles should still apply.

The important thing is that you are not duplicating your data, you are 
simply adding the minimum information required to describe your 
differences from the underlying data model.

Regards,

Rogan
-- 
Rogan Dawes

*ALL* messages to [EMAIL PROTECTED] will be dropped, and added
to my blacklist. Please respond to "nntp AT dawes DOT za DOT net"




==========================================================================
TOPIC: Compiler trick
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2992422eec9fe49
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 15 2004 1:20 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Joona I Palaste wrote:

> If we have two
> threads, one of which does A and B, the other does C and D, then the
> actual physical sequence may be A-B-C-D, A-C-B-D, A-C-D-B, C-A-B-D,
> C-A-D-B or C-D-A-B. It is always guaranteed that all four operations
> are done, A is done before B, and C is done before D. Nothing else
> about the ordering is guaranteed. (This is assuming a strictly
> sequential intra-thread execution with no control structures.)

I may be missing your point here, but I think that without synchronisation,
there is no such guarantee.  As it happens I've just written a passage in
another post which fits just as well here.  Apologies to anyone who sees it
twice ;-)

This is discussed in the Java Memory Model JSR, see:

http://www.cs.umd.edu/~pugh/java/memoryModel/PublicReview.pdf

Two threads, two shared variables A and B, two passages of code that access
them without synchronisation:

Initially A == B == 0

Thread 1:
    r2 = A;
    B = 1;

Thread 2:
    r1 = B;
    A = 2;

A legal result of this is that r2 == 2 and r1 == 1.  The JSR describes this as
"surprising behavoir".  Which is a classic bit of understatement...

    -- chris







==========================================================================
TOPIC: Thread synchronization
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/172837b7b0667fd1
==========================================================================

== 1 of 4 ==
Date:   Wed,   Sep 15 2004 1:24 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Thomas G. Marshall wrote:

> > > Particularly when the user grabs a thread safe list using
> > > Collections.synchronizedList().
> >
> > Ugh, yes!

> And how would you deal with my example then?  Let's make it a little more
> general:
>
>         // move our thing up x notches...
>         ourThing.set(ourThing.get() + x);  // not thread safe.  Kaboom.
>
> /THAT/ is a error waiting to happen (actually it's an error already if
> multithreading on a single instance).  What would you do?  If you create
> the following:

class MyClass
{
    private int ourThing thingness = 0;
    public synchronised get() { return thingness; }
    public synchronised increment(int by) { thingness += n; }
    // TODO: is this really needed ?
    public synchronised set(int n) { thingness = n; }
}

but it's doubtful whether I'd provide a public set() method unless there was
clear need for both set() and increment() as public operations.

Put into my terms.  Instances of MyClass accept responsibility for ensuring
that they can be increment()-ed in a thread-safe manner.  It is not the
/caller's/ responsibility to do so.

You may notice that this leads to broadening of the interface of MyClass -- I'm
entirely happy with that. Such broadening is (IMO) natural in decent OO code.
(As an aside, much Java code is not -- in this specific sense, and IMO -- very
well written.  The received wisdom is to keep classes lean, and to put the
logic in the caller.  But I think that just leads to a mess where
responsibility does not properly follow object boundaries.

    -- chris






== 2 of 4 ==
Date:   Wed,   Sep 15 2004 1:24 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Lee Fesperman wrote:
> Thomas G. Marshall wrote:

> > ...[rip]...
>
> By 'rip', I assume that means that [...]

I think Thomas uses "rip" where another would use "snip".  I admit that when I
first saw it, I took it as insulting -- something like "we don't need all
/this/ crud".

    -- chris






== 3 of 4 ==
Date:   Wed,   Sep 15 2004 1:25 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

xarax wrote:

> 32-bit updates and fetches are atomic.

The fetches and updates are atomic, but since there's no guarantees about when
they'll happen (in the absence of synchronisation or volatile variables), that
fact is of almost /zero./ use in practise.

If the 32-bit value is an object reference then clearly the atomicity is
valueless since there's no guarantee that the data "pointed to" will be become
visible across thread boundaries at the same time, so we can only be talking
about int-s (and similar).  Even there, you can't avoid synchronisation
usually.  Here's an example from the Java Memory Model JSR:

http://www.cs.umd.edu/~pugh/java/memoryModel/PublicReview.pdf

Two threads, two shared variables A and B, two passages of code that access
them without synchronisation:

Initially A == B == 0

Thread 1:
    r2 = A;
    B = 1;

Thread 2:
    r1 = B;
    A = 2;

A legal result of this is that r2 == 2 and r1 == 1.  The JSR describes this as
"surprising behavoir".  Which is a classic bit of understatement...

    -- chris







== 4 of 4 ==
Date:   Wed,   Sep 15 2004 1:25 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Mike Schilling wrote:

> "Chris Uppal" <[EMAIL PROTECTED]> wrote in message
> > I'm still not sure I'm following you.  Is your objection that without a
> > "hidden" lock object, it is possible for an arbitrary bit of foreign
> > code to
> > execute a synchronised block on the object in question, thus potentially
> > preventing it from making further progress in its real task ?
>
> No, it's that any class C can do a
>
>     synchronized(o)
>
> on any object o it has access to.  If that object is also synchronizing on
> itself, this can play havoc with its internal synchronization logic.
> Note that this is independent of how well the internal synchronization is
> encapsulated, or of whether the object's class is visible  to C.

As far as I can see, this is the same as I was asking; am I still
misunderstanding you ?


> I don't think
>
>     private Object lock_object();
>
>     synchronized(lock_object)
>
> differs in concept from
>
>     synchronized(this)
>
> particularly when you understand the reason for it.

Well, there are two possibilities that I can see.  One is that you are putting
the "edges" of synchronisation in the same places I would (i.e. the externally
visible temporal behaviour of all the visible objects is the same whether it's
coded in your style or mine).  If that is the case then the difference is
clearly fairly minor -- by definition -- but I would question why you are
choosing an relatively more obfuscated and potentially error-prone (e.g.
forgetting to make the lock object "final", as above ;-) expression, when Java
has a built-in expression that is easier to work with, and which does not
suggest that the program /might/ be doing something more complex than it
appears.  The other possibility is that you are designing your synchronisation
networks in a way that I would not, and that your synchronisation does not
primarily follow object boundaries.  If that is the case then I think that you
/are/ increasing the conceptual load, and even edging towards synchronisation
spaghetti, and while I'm sure /you/ can make it work well, it's not an approach
that I'd recommend in general.


> [re: "Effective Java"]
> I recommend it.  My experience was that some of it was well-known and
> obvious, while other parts were new and valuable.

I shall take another look next time I'm in the Big City. Thanks.

    -- chris








==========================================================================
TOPIC: Questions regarding object translation using JNI
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/931888db697efafe
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 15 2004 1:21 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Rowland wrote:

> I'm using the Java Native Interface to access a VB .NET library (albeit
> one which uses COM rather than .NET - don't ask!!!) which I do not want to
> rewrite in Java.
> I've got it working fine by writing wrappers in VB, but one function in
> this library will return an ADO recordset. I think I'm fairly safe in
> assuming that I cannot simply use the VB recordset in Java, so my
> question is : What techniques/technologies can be used to allow Java to
> interrogate objects created in a different language (Visual Basic ADO
> RecordSet's in this case, but I would prefer an answer for the more
> general case).

Nobody else has answered, so I'll risk an ignorant suggestion:

I'd have thought that your best bet would be to find a COM<->Java bridge (or
ActiveX<->Java bridge), of which there are several, including at least one
commercial product[*].  COM's objects are not /that/ unlike Java's, so you'd
end up using the ADO recordset as an object like any other.

([*] I think the name's "JNIWrapper" -- see Google)

    -- chris






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

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 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/BCfwlB/TM
--------------------------------------------------------------------~-> 

<a href=http://English-12948197573.SpamPoison.com>Fight Spam! Click Here!</a> 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/kumpulan/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to