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

Today's topics:

* Split with regular expressions - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2c7dcc86f463c843
* file upload using jsp - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b022087630d5c8b3
* How to write an efficient maximum function? - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f759ff7cc130859e
* useBean class attribute - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d72298aeadcce1f4
* Parameters in stylesheets - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1dc13800b4569de1
* RemoveChild and BlankSpace in the XML file. - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4ad5d051016990ed
* a small question about object-orientation - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e43e0bfef7abd768
* Servlet warning: Cannot.set.header.Response.already.committed. - 2 messages, 
2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c0a7eb2b4a8b8187
* XML String into a DOM object? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/922217d586d6571a
* How can I "force" an upcast? Convert subclass into superclass? - 1 messages, 
1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ad4bc9f7ae03de71
* UnsupportedEncodingException - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f05a57f2fc1fbd14
* CORBA or some other methodology? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a7b217bf697c503b
* How 'java' (command) handles the classname passed - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/908d4e10411ee318
* efficient network transfer - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6996ec6c1fb6cf53
* Compiling java code from within Java - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7dccb8de6fe57263
* Thread-question - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa
* loading a class whose bytecode comes in a byte[] - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4e991c30dd027000
* hey i am new to this - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1037fd04428c23dc
* references and a binary tree - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d897505b2c28f461
* tomcat css mime-type - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4f0bba1ea74e6ae5
  
==========================================================================
TOPIC: Split with regular expressions
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2c7dcc86f463c843
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 2:52 am
From: Chris Uppal <[EMAIL PROTECTED]> 

patrik wrote:

> I have a question concerning regular expressions:
> i have the following example string including quotas:
> 
> "bbbb cccc" "dddd eeee" "ffff"

If those strings can themselves contain quotes, either escaped:

     "aaa" "bbb \" ccc" "ddd"

or doubled-up:

     "aaa" "bbb "" ccc" "ddd"

then your regular expression is going to be that much more complicated 
(if you can work out how to do it at all).  I doubt if regular 
expressions are the right tool for this job -- not if you want 
production-quality code anyway.

     -- chris




==========================================================================
TOPIC: file upload using jsp
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b022087630d5c8b3
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 22 2004 3:27 am
From: "Kyle" <[EMAIL PROTECTED]> 

Hi,
I am writing a website part of which allows user to upload files into the
server. I am really new to jsp/servlet. Could anyone give me some tips on
what to do? Can I do this totally based on jsp and/or servlet?
Thanks in advance
Kyle





== 2 of 2 ==
Date:   Mon,   Nov 22 2004 4:13 am
From: Andrea Desole <[EMAIL PROTECTED]> 

it was too late for me when I found it out, but maybe you can take 
advantage of it:

http://jakarta.apache.org/commons/fileupload/


Kyle wrote:
> Hi,
> I am writing a website part of which allows user to upload files into the
> server. I am really new to jsp/servlet. Could anyone give me some tips on
> what to do? Can I do this totally based on jsp and/or servlet?
> Thanks in advance
> Kyle
> 
> 




==========================================================================
TOPIC: How to write an efficient maximum function?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f759ff7cc130859e
==========================================================================

== 1 of 3 ==
Date:   Mon,   Nov 22 2004 3:56 am
From: [EMAIL PROTECTED] (Jesper Nordenberg) 

Ahmed Moustafa <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Hello,
> 
> What would be the most efficient to write a maximum function in Java?

I've only found one that is optimal for integers:

private static int maximum(int a, int b, int c, int d) {
  for (int i=Integer.MIN_VALUE; i<=Integer.MAX_VALUE; i++) {
    if (i > a && i > b && i > c && i > d)
      return i - 1;
  }

  throw new RuntimeException("Something is wrong with your integers!");
}


Sorry, bad joke ;-)

/Jesper Nordenberg



== 2 of 3 ==
Date:   Mon,   Nov 22 2004 5:16 am
From: Alex Hunsley <[EMAIL PROTECTED]> 

Boudewijn Dijkstra wrote:
> "Ahmed Moustafa" <[EMAIL PROTECTED]> schreef in bericht 
> news:[EMAIL PROTECTED]
> 
>>Hello,
>>
>>What would be the most efficient to write a maximum function in Java?
>>
>>Initially, I had the comparisons that looked for the maximum inside
>>the main method and then moved it inside its own method (code is
>>below) to be called from within the main method (to make the code look
>>prettier), but that cost me almost 3 additional seconds processing
>>time:
>>
>><code>
>>private static float maximum (float a, float b, float c, float d) {
>>float t1 = a > b ? a : b;
>>float t2 = c > d ? c : d;
>>return t1 > t2 ? t1 : t2;
>>}
>></code>
> 
> 
> That method always runs in the same amount of VM ticks.  It takes:
> - 3 comparisons;
> - 3 copies; and
> - 3 jumps.
> 
> How about:
> 
> private static float maximum(float a, float b, float c, float d)
> {
>   float max = a;
>   if (b > max) max = b;
>   if (c > max) max = c;
>   if (d > max) max = d;
>   return max;
> }
> 
> which takes:
> - 1..4 copies;
> - 3 comparisons; and
> - 3 jumps.
> 
> The average number of copies is calculated as follows:
> if a is maximum: 1 copy
> if b is maximum: 2 copies
> if c is maximum: 3 copies
> if d is maximum: 4 copies
> average copies = (1 + 2 + 3 + 4) / 4 = 10 / 4 = 2.5
> 
> Note that 2.5 < 3

I was going to suggest the same code structure as you wrote, but merely 
because it's much more readable and obvious if you've written it wrong!



== 3 of 3 ==
Date:   Mon,   Nov 22 2004 6:54 am
From: "Thomas G. Marshall" <[EMAIL PROTECTED]> 

Jesper Nordenberg coughed up:
> Ahmed Moustafa <[EMAIL PROTECTED]> wrote in message
> news:<[EMAIL PROTECTED]>...
>> Hello,
>>
>> What would be the most efficient to write a maximum function in Java?
>
> I've only found one that is optimal for integers:
>
> private static int maximum(int a, int b, int c, int d) {
>   for (int i=Integer.MIN_VALUE; i<=Integer.MAX_VALUE; i++) {
>     if (i > a && i > b && i > c && i > d)
>       return i - 1;
>   }
>
>   throw new RuntimeException("Something is wrong with your
> integers!"); }
>
>
> Sorry, bad joke ;-)
>
> /Jesper Nordenberg


I think a thread on how to write the worst max function would be the most
interesting of all!




-- 
"It's easier to be terrified by an enemy you admire."
-Thufir Hawat, Mentat and Master of Assassins to House Atreides






==========================================================================
TOPIC: useBean class attribute
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d72298aeadcce1f4
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 4:05 am
From: [EMAIL PROTECTED] (George Kentman) 

Hi there,

I am operating with JBoss4 and Tomcat5.
Jasper throws me an exception because of an invalid value for the
class attribute.
Path is set correct also in the WAR-File.
The problem seems to be that the class isn't a bean.
Therfore I changed the errorOnUseBeanInvalidClassAttribute flag in
Tomcat to false, but that didn't help either.
Does anyone know how to handle that problem?

Cheers




==========================================================================
TOPIC: Parameters in stylesheets
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1dc13800b4569de1
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 4:03 am
From: Alexey Dmitriev <[EMAIL PROTECTED]> 

Hi all...

I set parameter for transformer, but actual output is not valid as expected.

Scrap of code
--------------
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new 
StreamSource("foo.xsl"));
transformer.setParameter("param1", ".");
transformer.transform(new StreamSource("foo.xml"), new StreamResult(new 
OutputStreamWriter(System.out)));

Input xml
------------
<doc>Hello</doc>

Input xsl
------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">
   <xsl:param name="param1"  select="'default value'"/>
   <xsl:template match="doc">
     <out><xsl:value-of select="$param1"/></out>
   </xsl:template>
</xsl:stylesheet>

Actual output
------------
<out/>

Expected output (in my mind)
-----------------------------
<out>Hello</out>

What's wrong? Why actual output don't contain "Hello"?

Environment: j2sdk1.4.2_04

--
Alex




==========================================================================
TOPIC: RemoveChild and BlankSpace in the XML file.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4ad5d051016990ed
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 22 2004 4:28 am
From: [EMAIL PROTECTED] (Achille) 

Hi all,
I need to remove a node in my XML file. 
I use the DOMParser.

If I use the removeChild, the node is removed but a white line remains
in my Dom tree and file xml.

How do I also do to remove the blanck line?

Thanks!
By 
Achille



== 2 of 2 ==
Date:   Mon,   Nov 22 2004 4:55 am
From: Alexey Dmitriev <[EMAIL PROTECTED]> 

Achille wrote:

> Hi all,
> I need to remove a node in my XML file. 
> I use the DOMParser.
> 
> If I use the removeChild, the node is removed but a white line remains
> in my Dom tree and file xml.
> 
> How do I also do to remove the blanck line?
> 
> Thanks!
> By 
> Achille
if the parser has not been set in a validating mode 
(DocumentBuilderFactory.isValidating{}) It's connected by that spaces or 
line carring between anyone two consecutive elements of DOM are treated 
as a TextNode.
There is only one way to avoid it is it to set a validating mode and set 
a ignoring whitespaces.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setIgnoringElementContentWhitespace(true);
builder = factory.newDocumentBuilder();
...

Anyway If you know document structure You can remove nasty text nodes 
itself.

--
Alex




==========================================================================
TOPIC: a small question about object-orientation
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e43e0bfef7abd768
==========================================================================

== 1 of 3 ==
Date:   Mon,   Nov 22 2004 5:05 am
From: [EMAIL PROTECTED] (Tommy) 

I have just started java-programming (Deitel), and have read about
classes and member classes.
Let's say I have a class Car, and this class has some private members
and private functions. Any functions that is not a member of a car
denies access, to those functions and variables in Car. Is it the
compiler which controls this access control or what? How is this done?



== 2 of 3 ==
Date:   Mon,   Nov 22 2004 5:25 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

Tommy wrote:

> I have just started java-programming (Deitel), and have read about
> classes and member classes.
> Let's say I have a class Car, and this class has some private members
> and private functions.

In Java, it's "methods", not "functions".

> Any functions that is not a member of a car
> denies access, to those functions and variables in Car. Is it the
> compiler which controls this access control or what? How is this done?

Both the compiler and the runtime system check visibility rules. However,
this should not be thought of as "access control", since it can be
circumvented via reflection, see the class java.lang.reflect.AccessibleObject.

Visibility restrictions have nothing to do with security, they're about
code organization. Public members form an API that other classes written
by other people may rely on. By making a member private, the programmer
says "this is internal stuff, it can change whenever I feel like it and
is really none of your business".



== 3 of 3 ==
Date:   Mon,   Nov 22 2004 8:06 am
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Tommy wrote:

> I have just started java-programming (Deitel), and have read about
> classes and member classes.
> Let's say I have a class Car, and this class has some private members
> and private functions. Any functions that is not a member of a car
> denies access, to those functions and variables in Car. Is it the
> compiler which controls this access control or what? How is this done?

You might want to start out next door on comp.lang.java.help, which is 
more suited to beginners.  I have crossposted this response to that 
group, and directed followups there.

Terminology: Java classes do not have functions, they have methods.

Answer: The compiler checks access to class members at compile time, and 
the virtual machine checks again at run time.  "How" is probably not a 
pertinent question, or at least not a sufficiently specific one.


John Bollinger
[EMAIL PROTECTED]




==========================================================================
TOPIC: Servlet warning: Cannot.set.header.Response.already.committed.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c0a7eb2b4a8b8187
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 22 2004 5:38 am
From: [EMAIL PROTECTED] (Ulas Ergin) 

Hi,
I have a simple application that sends http request to a servlet via
URLConnection.It prints Cannot set header. Response already committed.
warning message to the stdout of servlet.

What is wrong with the below code segment?


while (result.next()) {
  java.net.URL dataURL = new
java.net.URL("http://localhost/MyServlet";);
  java.net.URLConnection connection1 = dataURL.openConnection();
  connection1.setUseCaches(false);
  connection1.setDoOutput(true);
  connection1.setDoInput(true);                         
  String data = result.getString(5) 
  String postData = new String("user=X&type=WEB&id=");
  postData = postData + data;
  java.io.DataOutputStream printout = new java.io.DataOutputStream
(connection1.getOutputStream());
  printout.writeBytes(postData);
  printout.flush();
  printout.close();             
  java.io.BufferedReader input = new java.io.BufferedReader(new  
java.io.InputStreamReader(connection1.getInputStream()));
  String line = null;
  StringBuffer returnedFBML = new StringBuffer();
  while ((line = input.readLine()) != null) {
    returnedFBML.append(line + "\n");
  }
  input.close();
}
 



and the log is

[22.11.2004 11:00:27:339 MSK] 2b8d8aac SRTServletRes W WARNING: Cannot
set header. Response already committed.
[22.11.2004 11:00:27:382 MSK] 31140aac TraceNLS u No message text
associated with key WARNING:.Cannot.set.header..Response.already.committed.
in bundle com.ibm.ejs.resources.seriousMessages



== 2 of 2 ==
Date:   Mon,   Nov 22 2004 6:18 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

Ulas Ergin wrote:

> Hi,
> I have a simple application that sends http request to a servlet via
> URLConnection.It prints Cannot set header. Response already committed.
> warning message to the stdout of servlet.
> 
> What is wrong with the below code segment?

For one thing, it doesn't compile - there's a semicolon missing. So it can't
be the code you executed. But it doesn't really matter because the error is
in the servlet, not the client.

The servlet tries to set a HTTP response header after having written more output
data than fits into the buffer. Since HTTP headers are sent *before* the content
of a message, they cannot be set after you've started sending the content.




==========================================================================
TOPIC: XML String into a DOM object?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/922217d586d6571a
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 22 2004 5:46 am
From: "davout" <[EMAIL PROTECTED]> 

A newbie question: how do I transform an XML string into a DOM document 
object?

I see that the various Xerces builder classes have 'parse' methods for files 
and streams, but I can't see anything that has the source as a String value.








== 2 of 2 ==
Date:   Mon,   Nov 22 2004 6:11 am
From: "Murray" <[EMAIL PROTECTED]> 


"davout" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> A newbie question: how do I transform an XML string into a DOM document
> object?
>
> I see that the various Xerces builder classes have 'parse' methods for
files
> and streams, but I can't see anything that has the source as a String
value.

Reader reader = new StringReader(myString);
InputSource source = new InputSource(reader);
Document doc = parser.parse(source);






==========================================================================
TOPIC: How can I "force" an upcast? Convert subclass into superclass?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ad4bc9f7ae03de71
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 6:13 am
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Mike Schilling wrote:

> "John C. Bollinger" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>>(a) Original formulation of the Liskov Substitution Principle: "If for 
>>each object o1 of type S there is an object o2 of type T such that for all 
>>programs P defined in terms of T, the behavior of P is unchanged when o1 
>>is substituted for o2 then S is a subtype of T."
>>
>>(b) Take type T as java.lang.Object
>>
>>(c) Take type S as:
>>    public class S {
>>        int i;
>>        public S(int ii) {
>>            this.i = ii;
>>        }
>>        public boolean equals(Object o) {
>>            if (o.getClass() == this.getClass()) {
>>                return (((S) o).i == this.i);
>>            } else {
>>                return false;
>>            }
>>        }
>>    }
>>
>>(d) Take the class of programs, P, characterized by integer 
>>PROGRAM_PARAMETER and the following Java source code:
>>
>>public class EqualityTester {
>>    public boolean areObjectsEqual(Object a, Object b) {
>>        return a.equals(b);
>>    }
>>    public static void main(String[] args) {
>>        Object o2 = new Object();
>>        Object obj = new S(PROGRAM_PARAMETER);
>>
>>        System.out.println(areObjectsEqual(o2, obj)
>>                           ? "Equal" : "Not Equal");
>>    }
>>}
>>
>>All of those programs print "Not Equal".
>>
>>(e) Choose, then, any instance, o1, of class S, and substitute it for o2 
>>in all the programs P.   There will be one of those programs that then 
>>prints "Equal" instead of "Not Equal" -- i.e. the behavior of one of the 
>>programs changes.  Note that this is independent of the choice of object 
>>o1, so long as that object's class is java.lang.Object.  If Liskov were 
>>obeyed then that would imply that S is not a subclass of Object, but that 
>>is incorrect, hence Liskov is not obeyed.
>>
> 
> 
> Perhaps I'm missing something, but I don't see that overriding Equals is 
> necessary for this kind of example.  Change the example program in (d) to 
> the following:
> 
> public class EqualityTester {
>     public boolean areObjectsEqual(Object a, Object b) {
>         return a.equals(b);
>     }
>     public static void main(String[] args) {
>         Object o2 = new Object();
>         Object obj = new S(PROGRAM_PARAMETER);
> 
>         System.out.println(areObjectsEqual(o2.getClass(), obj.getClass())
>                            ? "Equal" : "Not Equal");
>     }
> }
> 
> All will print "Not Equal".  Now, as before, choose, then, any instance, o1, 
> of class S, and substitute it for o2
>  in all the programs P. All will now print "Equal".  This would continue to 
> be true if S didn't override equals().

The point was to satisfy this part of the Liskov principle: "for all 
programs P _defined in terms of T_" (emphasis mine).  Perhaps I have not 
achieved that satisfactorily.  Also, however, I argue that asking about 
the objects' classes is cheating in some sense -- if you permit that, 
then Liskov forbids subclassing altogether.  (Yes, I use getClass() in a 
typical way in S.equals(); the demonstration does not depend on this 
being the case, but it is simplified by it.  Any equals() implementation 
that renders an S equal to any object distinct from itself would do.)

> I'm tempted to go on to discuss the invariant:
> 
>     a != b -> !a.equals(b)
> 
> This is true for objects of type Object(), but overriding equals() can 
> violate it. Since I'm not sure if I'm missing your point entirely, I'll not 
> do that now. 

Well, now, go ahead and provide a simpler example, why don't you?  ;-) 
Yes, that relationship can be used to construct a similar demonstration. 
  Consider, then, that similar problems do not necessarily occur in 
other method overriding scenarios; according to Liskov, such problems 
*never* occur in a well-formed class hierarchy.  *That* is the point.


John Bollinger
[EMAIL PROTECTED]





==========================================================================
TOPIC: UnsupportedEncodingException
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f05a57f2fc1fbd14
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 22 2004 6:21 am
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Tor Iver Wilhelmsen wrote:

> "Bill Lattery via JavaKB.com" <[EMAIL PROTECTED]> writes:
> 
> 
>>When I try to compile I get this message:
>>
>>"unreported exception java.io.UnsupportedEncodingException; must be
>>caught or declared to be thrown"
>>
>>Why do I get this?
> 
> 
> Because you call a method that is DOCUMENTED to throw an unchecked
> exception by that name. You either need to declare your method to
> throw it, or surround the call to getBytes() with try/catch.

Documentation has little to do with it.  UnsupportedEncodingException is 
a *checked* exception that the method being invoked is declared to be 
capable of throwing, therefore the method that invokes it must either 
catch that exception or declare that it throws it.  This is _never_ the 
case for unchecked exceptions, whether they are declared in a throws 
clause or not.


John Bollinger
[EMAIL PROTECTED]



== 2 of 2 ==
Date:   Mon,   Nov 22 2004 7:45 am
From: "Bill Lattery via JavaKB.com" <[EMAIL PROTECTED]> 

Thanks Andrew!

You method works.

Now, I have another problem.

I am working with a Java-based program that performs SNMP. One of the MIB 
variables is a 6 byte octet message stream. The program retrieves the 
information and saves it on a table as a String. My part of the code must get 
the info as a String. I need to convert the String to a byte buffer.  

The problem I have is that not all of the data is encoded properly.

For example: The MIB variable message is (in decimal): 00 04 -127 12 -115 -114

When I use the getBytes() function, the byte buffer contains (in decimal): 00 
04 63 12 63 63. 

I have used the Character Encoding Sets  US-ASCII, ISO-8859-1, UTF-8, UTF-16, 
UTF-16BE, UTF-16LE, and windows-1252. None have given me the result I need. 

What Character Encoding Set should I use to get the right values? 

Thanks.

-- 
Message posted via http://www.javakb.com




==========================================================================
TOPIC: CORBA or some other methodology?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a7b217bf697c503b
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 6:37 am
From: Bruno Grieder <[EMAIL PROTECTED]> 

Ted Holden wrote:
> On Thu, 18 Nov 2004 19:28:40 +0100, Bruno Grieder
> <[EMAIL PROTECTED]> wrote:
> 
> 
>>Cannot be simmpler: www.xmlrpc.com
>>and for C/C++ 
>>http://xmlrpc-c.sourceforge.net/xmlrpc-howto/xmlrpc-howto-c.html
>>
>>Bruno
> 
> 
> 
> Thanks!
> 
> One other question.  XMLRPC and SOAP/AXIS have been suggested here as
> alternatives to CORBA.  There is one other thing which CORBA does
> which I might or might not need for this particular application but
> which is nice to have as a general rule, and that is to maintain some
> notion of state in the sense that an application which needs one
> generates an object of a particular type for itself and holds onto it
> as long as it needs it for whatever it is doing, which might require a
> number of method calls for the object being used and not just one.
> State is maintained in the objects data members while that is going
> on.
> 
> Do xmlrpc and/or SOAP/Axis have this same capability?  In particular,
> the documentation for xmlrpc appeared to be a little thin and it
> wasn't totally obvious.
> 
> 
That sounds like a stateful session bean! (too bad you app is written in 
C++, not in Java).

I am not sure I understand your question: session management is a server 
side issue more than anything else. Can your C++ app maintain a session?

Please note that - officially - web services do not maintain sessions 
state. Now, in Java, there are ways around this using the session context.

b.




==========================================================================
TOPIC: How 'java' (command) handles the classname passed
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/908d4e10411ee318
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 6:55 am
From: Chris Smith <[EMAIL PROTECTED]> 

Tor Iver Wilhelmsen <[EMAIL PROTECTED]> wrote:
> Chris Smith <[EMAIL PROTECTED]> writes:
> 
> > I'm in picky mode today.  It would look for "classname/class.class", 
> > actually, where '/' is actually the platform-dependent file separator.  
> 
> Now you are assuming things about the ClassLoader. A VM can perfectly
> well default to a ClassLoader that reads classes from a database or
> something, e.g. SELECT CLASS_DATA FROM CLASSES WHERE PACKAGE_NAME =
> 'classname' AND CLASS_NAME = 'class'

In a discussion about the command line parameters that should be passed 
to the JRE, of course I'm assuming things about the VM.  Otherwise, the 
conversation is impossible to have.  There is no specification that 
covers which command-line arguments should be accepted by a virtual 
machine.

-- 
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation




==========================================================================
TOPIC: efficient network transfer
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6996ec6c1fb6cf53
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 22 2004 6:58 am
From: [EMAIL PROTECTED] (uzon) 

keep your "suggestions" to yourself. this is a java forum not grammar and 
spelling. 
troll isn't name calling. it's a description of your precious and unique 
attitude.



== 2 of 2 ==
Date:   Mon,   Nov 22 2004 7:28 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 22 Nov 2004 06:58:50 -0800, uzon wrote:

> keep your "suggestions" to yourself. 

Plonk whoever your wish.

> this is a java forum 

Yes, it's a discussion forum for the Java programming 
language, conducted primarily in English.  

Such discussions are made simpler for all concerned (including 
the large number of contributors who speak English as a second 
language) if the poster makes every effort to be understood.

This effort amounts to including such boring and mundane things 
as putting a space between paragraphs and capitalising the first 
letter of sentences.

>...not grammar and spelling. 

You seem to be ignoring the 15 lines of my post that did not
mention grammar and spelling.  For reference, I'll link to it..
<http://groups.google.com/[EMAIL PROTECTED]>

You might even visit, and benefit from, the links I included.

> troll isn't name calling. it's a description of your precious and unique 
> attitude.

Pot, kettle, black.  Get over it, and please locate your shift key.

-- 
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: Compiling java code from within Java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7dccb8de6fe57263
==========================================================================

== 1 of 3 ==
Date:   Mon,   Nov 22 2004 7:07 am
From: [EMAIL PROTECTED] (John Morey) 

Hi

I am working on a program to test java code, my program needs to be
able to know if a certain class (loaded from a .java file) would
compile properly via a java compiler.

What would be the best method of doing this? I have looked at the
Compiler class but this does looks like something intended for use
within the java virtual machine itself...

thanks for any help



== 2 of 3 ==
Date:   Mon,   Nov 22 2004 7:27 am
From: "John Harlow" <[EMAIL PROTECTED]> 

John Morey wrote:
> Hi
>
> I am working on a program to test java code, my program needs to be
> able to know if a certain class (loaded from a .java file) would
> compile properly via a java compiler.
>
> What would be the best method of doing this? I have looked at the
> Compiler class but this does looks like something intended for use
> within the java virtual machine itself...
>
> thanks for any help

exec javac? 





== 3 of 3 ==
Date:   Mon,   Nov 22 2004 7:48 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

John Morey wrote:
> I am working on a program to test java code, my program needs to be
> able to know if a certain class (loaded from a .java file) would
> compile properly via a java compiler.
> 
> What would be the best method of doing this? I have looked at the
> Compiler class but this does looks like something intended for use
> within the java virtual machine itself...

A compiler API is being planned (JSR 191), but not currently avilable.
Thus, you have to calling Sun's javac either through Runtime.exec()
or directly via com.sun.tools.javac.Main (it's in tools.jar) and
live with its restrictions (only an integer return code, only files
as input) - or use a separate compiler such as IBM's Jikes or the
one eclipse uses. They probably have a richer API.




==========================================================================
TOPIC: Thread-question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 7:34 am
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Chris Uppal wrote:

> John C. Bollinger wrote:
> 
> 
>>>Actually, I'd prefer to have beFinalizable() and beNotFinalizable() as
>>>(probably protected) methods of Object, and for "finalisability" to be
>>>off for all objects, by default, regardless of whether they defined a
>>>finalize() method.  I.e. it should be the programmer's responsibility
>>>to manipulate finalisability as necessary, not left up to an
>>>ill-defined system "optimisation".
>>
>>I think I have to disagree with you on this one, Chris.  The programmer
>>can already control this dimension to a limited extent by deciding
>>whether or not to override Object.finalize().  To be sure, that's a
>>per-class decision, not a per-object one, but I think that's where the
>>decision belongs.
> 
> 
> It's probably "agree to differ" time then ;-)   At a guess you a reasoning at
> least partly by analogy with ordinary GC, where /not/ leaving memory
> allocation/deallocation under the control of the programmer has too many
> advantages to list ?

I think I'm coming more from the point of view that Java finalization is 
inherently unsuited to so many kinds of tasks that I would prefer to not 
offer additional hooks -- it would just make it that much easier to 
write broken code.

In fact, I think I am shifting my stance on finalization in general from 
"I don't know what it's good for" to "it isn't good for anything." 
Objects may not be finalized within any particular time frame, or even 
finalized at all, so finalization is fundamentally unsuited to managing 
limited resources, and especially unsuited to managing resources whose 
states persist beyond the end of program execution.  What, then, could 
finalization be used for?  It has to be something that the program would 
prefer to happen after an object becomes unreachable, but which it can 
accommodate never happening.  I can only imagine some use related to 
monitoring the GC process itself, but I reject that as something that 
the program should not be concerning itself with.  I'm open to other 
suggestions.

> My position is that finalization itself is a fairly "heavy-weight" operation,
> and as such is less well-suited to automation.  Mainly because there's more to
> loose when (or if) the system doesn't handle it as well as I/we could if we
> were doing it by hand.  (There's a definite parallel there with closing file
> handles, which are too heavyweight to be suitable for handling completely
> automatically -- by finalisation, for instance ;-)

I'll claim that as an argument in favor of my new position against 
finalization in general.

> The other reason I favour the more explicit approach is that I work with it
> often and find it "feels" better (as I've mentioned before, I do more work in
> Smalltalk than Java, and that's how the implementation I use works).  There is
> an efficiency gain, of course, to being able to turn finalisation on only as
> and when needed (during any specific object's total lifetime), and I don't
> think that should be ignored.  But the other side of the coin is that I find
> that code with explicit control of finalisation is actually /clearer/ than the
> equivalent would be in Java.   That's because the normal pattern (virtually
> universal) is that you do a (using Java syntax)
>     this.beFinalizable();
> at the time when you acquire a resource that must be released (such as an open
> OS file handle  -- this is internal to the object that wraps that handle, of
> course); and you do a
>     this.beNotFinalizable();
> at the time when you relinquish that resource.  I find that those methods act
> as flags that show very clearly how the object does its resource management.
> You might say that they form the skeleton of the design, and once you can see
> that clearly, then it's easier to see where the flesh fits around it.

At least for Java, that's a broken design paradigm.  If you need to be 
certain that resources are released then you cannot depend on 
finalization to do it.  In fact, the place where that paradigm makes the 
most language-neutral sense is in the context of abnormal program 
termination, where it might be expected to provide an alternative route 
for cleaning up resources.  In Java, however, that is precisely the 
scenario where it is _least_ likely that objects will be finalized.

You can in any case provide a very similar feature within Java by 
placing a mutable "needsToBeFinalized" flag in your classes, and having 
a finalize method that tests it as a condition for doing anything 
(else).  In that I am now opposing using finalization for anything, I 
won't advocate building that sort of thing into the language.

> I find it particularly helpful in cases where the object is normally cleaned 
> up
> explicitly, but may also be handled by finalisation as a fall-back for when
> explicit clean-up would overcomplicate the design.  In such cases it can be
> difficult to get a handle on where the responsibility lies  -- which methods
> you /may/ call, which ones you /must/ call, which ones you must /not/ call 
> more
> than once...   In such cases I start by looking for
> beFinalizable()/beNotFinalizable() and the whole thing then normally becomes
> crystal clear.

That sounds like a design issue to me.  If there is a complicated 
cleanup sequence then it ought to be wrapped up in some method.  You'll 
need that anyway if you want the finalizer to be able to clean up 
properly.  If you can wrap it up in a method, then you can invoke that 
method wherever you might invoke beNotFinalizable().  Am I missing 
something here?

>>Do you have a concrete-ish example of how your version of finalization
>>management would be an improvement over what Java already offers?
> 
> 
> Two somewhat indirect examples, and coming from slightly different directions.
> I don't know how convicing you'll find them, but at least they are both real
> examples, taken from the Smalltalk system I work with:
> 
> Database connections, and other similarly heavy-weight database-related 
> objects
> (prepared statements, etc) are best cleaned up explicitly (IMO).  They also 
> may
> be complicated enough (internally) for the concerns that Gordon mentioned
> (keeping object networks alive, etc) to be an issue in practise.  However it
> would also be unthinkable (for various reasons) not to make open DB 
> connections
> clean up by finalisation, where necessary.  Notice also that DB code can (in

In Smalltalk perhaps that scenario would be unthinkable, but in Java you 
cannot count on the connection being finalized anyway, so you need to 
rely on the connection user to clean it up.  You _could_ write cleanup 
code into a finalizer, and that might rescue some broken programs, but 
it might also disguise the problems in such programs.  I would rather 
have my program fail sooner and more consistently.

> some cases) place considerable strain on the finaliser thread since the code
> may not be interactive (so no handy pauses to work in while the user thinks).
> The end result of that is that you want to be able to turn off 
> "finalisability"
> in the clean-up code, or else you have to write extra code to ensure that the
> cleaned-up but still finalisable object puts as little strain on the system as
> possible.

That sounds like an issue that could be handled by appropriate coding of 
the finalize() method, if you're going to rely on finalization at all. 
The difference between Java providing a feature to bypass the finalize() 
method and the programmer providing a feature to toggle finalize() 
between "do something" and "do nothing" is insignificant as far as I can 
see.  I'd relegate the feature to the "syntactic sugar" category.  Of 
course, these days it seems that items in that category have a 
reasonably good chance of being implemented....

> The other example is about managing Windows GDI handles.  In this case the
> resource to be managed is quite lightweight, and there's no great problem with
> relying mostly on finalisation to clean-up (which simplifies the system very
> considerably, or at least allows significantly greater flexibility for a given
> degree of complexity).  What /is/ a problem is understanding how the handles
> are managed, especially since some are "owned", and must be cleaned up, and
> some are "shared" and must /not/ be cleaned up, but the two are otherwise
> interchangeable.  In this case I think the biggest benefit of explicit control
> of finalisation is just that: it /is/ explicit.  It makes it easier to
> understand how that part of the system fits together.

It seems to me that handling resources such as these demands classes 
that understand the resources better, rather than classes that require 
the user to manipulate instances correctly, for some varying definition 
of "correctly".  You might not need distinct classes for "owned" and 
"shared" handles, but you could at least provide an internal flag to 
distinguish instances with respect to that characteristic.  The objects 
ought to encapsulate the knowledge of how they need to be cleaned up, 
and provide a uniform face to users.


So, then, I guess we do have to agree to disagree.  I am not persuaded 
by your examples, and I doubt whether you have been persuaded by my 
commentary on them.  Particularly as you have raised personal preference 
and style as a contributing factor, I have no reason to expect to change 
your mind.  (And, for the record, I feel no special need to do so.)


John Bollinger
[EMAIL PROTECTED]




==========================================================================
TOPIC: loading a class whose bytecode comes in a byte[]
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4e991c30dd027000
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 7:44 am
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Luca Rosellini wrote:

> John C. Bollinger ha scritto:
>> To make a scheme like this work, you would need to insert a more 
>> flexible custom ClassLoader somewhere much deeper in the application's 
>> ClassLoader tree, perhaps [for the sake of convenience] as the 
>> ClassLoader for everything except an "application launcher" class.  
>> You would obviously not be able to use a one-off ClassLoader for such 
>> a purpose.
> 
> 
> Is this really possible to achieve?

I think so.

> I mean, I could write my own classloader, but it would still need to 
> delegate to {system|extension|bootstrap}classloader the loading of core 
> classes. Since ObjectInput is a core class, it's classLoader doesn't 
> know how to find the class even though my own global app classloader does.

As I understand it (and my understanding may be flawed) classes keep 
track of the ClassLoader from which they were originally requested, even 
if that ClassLoader delegated the actual loading.  Otherwise Java would 
have to be considerably more magical than I think it is.  Why don't you 
write a small application to test it?  It wouldn't take much code to 
simulate the specific kind of usage paradigm we're talking about here.

> Unfortunately RMI are not usable for this kind of application.

Well, you know your own requirements.


John Bollinger
[EMAIL PROTECTED]




==========================================================================
TOPIC: hey i am new to this
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1037fd04428c23dc
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 7:47 am
From: [EMAIL PROTECTED] (Greg Smith) 

> But since I have your attention, please locate your Shift Key*
> and type capital letters for the beginning of sentences, the word 
> 'I' and proper names like 'Tamer' and 'Java'.  You are likely to 
> get better responses if you take effort to make your posts easy to read.

it has become very common on the internet not to use capital letters.
the fact is that it is faster to type and offers no loss in
readability. i had no trouble reading the posting and i've never been
critcized for my lack of caseness in my writings. surely, to complain
about lack of case in emails or postings is akin to insisting on
proper grammer and spelling in an instant message.




==========================================================================
TOPIC: references and a binary tree
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d897505b2c28f461
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 7:57 am
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Andrew Thompson wrote:

> On Sun, 21 Nov 2004 16:18:09 +0100, Stefan Schulz wrote:
>>What happens? NullPointerException? StackOverflowErrror?
>>WannaGoForAWalkError? ..
> 
> 
> My money is on WannaGoForAWalkError.

No, no, that's the cause of the HeSaysHesNotDeadError that's thrown.

:-)


John Bollinger
[EMAIL PROTECTED]




==========================================================================
TOPIC: tomcat css mime-type
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4f0bba1ea74e6ae5
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 22 2004 8:03 am
From: [EMAIL PROTECTED] (jt) 

Hello,

I'm using Tomcat 3.3.2 with Apache 1.3.26 .
I can't set proper mime-type for my "css" files, though I have this section in
my /WEB-INF/web.xml:

<mime-mapping>
        <extension>css</extension>
        <mime-type>text/css</mime-type>
</mime-mapping>

I include the "css" with a "link" tag in  "jsp" files:

<link type="text/css" rel="stylesheet" ref="./style/style.css" />

The "css" file is sent as "text/plain" and Firefox won't interpret it (now
that's the problem).

Could someone tell me what I missed?

-- 
jt



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

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