comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Does this finally get executed ? - 8 messages, 6 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e0d9fa26e656cf72 * Homework - Was Re: java programe help - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fddd0a49ac12937 * Sinking in the JAVA quicksandbox - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c50f4e3273d0e1bb * multiple forms and one servlet - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4dacdcfce2b3903e * regex: remove file ext - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9292732e966a520c * Possible HttpURLConnection.setFollowRedirects bug?I - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1f66b5ed7610a9b5 * Help please - Why does ByteBuffer return '?' as opposed to what was put? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d3036bb0e4e92e4 * why does ObjectInputStream constructor block reading a header - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7b8520ff9f293b96 * Setting up a filter based on server name - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/801866155eeb6057 * Student.HELP.Why does this code not compile? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1d7d030348369c72 * MMS Protocol and JMF - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c858bbcbd26b2947 * JavaScript or JavaApplet basic encryption suggestion - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/34c7bbef4bb229a8 * rules engines: faster implementation than methods invocations? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fe7838a641d72733 * help with internationalization/localization - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b2947dc6ffc5f377 * SOAP and servlets living together? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2dca87f4c115f04c ========================================================================== TOPIC: Does this finally get executed ? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e0d9fa26e656cf72 ========================================================================== == 1 of 8 == Date: Fri, Oct 29 2004 3:14 pm From: Chris Smith <[EMAIL PROTECTED]> [EMAIL PROTECTED] says... > > Yes, finally is always executed. > > I think the only exception is calling System.exit(0) > > There are other exceptions: > - throwing an exception from within a finally block. > - explicitly returning from within a finally block. > Both of these should be avoided as a matter of form. Neither of these cases will prevent a finally block from executing. They might, however, prevent it from completing normally and therefore cause an exception to be ignored; perhaps that's what you're thinking of. -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation == 2 of 8 == Date: Fri, Oct 29 2004 3:15 pm From: Lasse Reichstein Nielsen <[EMAIL PROTECTED]> "Tony Morris" <[EMAIL PROTECTED]> writes: >> Yes, finally is always executed. >> I think the only exception is calling System.exit(0) > > There are other exceptions: > - throwing an exception from within a finally block. > - explicitly returning from within a finally block. In both cases, the finally block *is* executed. It's just that perhaps not all of it is, but that's not much different from: try { ... } finally { if (false) { ... } } /L -- Lasse Reichstein Nielsen - [EMAIL PROTECTED] DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.' == 3 of 8 == Date: Fri, Oct 29 2004 3:54 pm From: "Tony Morris" <[EMAIL PROTECTED]> I apologise for the ambiguity. This is what I meant. By "executing a finally block", I meant executing from start to end as is often (should be) intended. -- Tony Morris http://xdweb.net/~dibblego/ == 4 of 8 == Date: Fri, Oct 29 2004 4:02 pm From: "Tony Morris" <[EMAIL PROTECTED]> > In both cases, the finally block *is* executed. It's just > that perhaps not all of it is, but that's not much different > from: > try { > ... > } finally { > if (false) { ... } > } Not quite. There is a difference. Generally, one is very nasty (returning or throwing from a finally); and one isn't (an if construct in a finally block - perfectly legitimate). Google appears to have thousands of explanations. -- Tony Morris http://xdweb.net/~dibblego/ == 5 of 8 == Date: Fri, Oct 29 2004 4:30 pm From: "Ann" <[EMAIL PROTECTED]> "GIMME" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Psuedo code ... > > Does sc.close() get executed ? > > public static Employee get(int id ) throws Exception > { > try { > SomeConnection sc = new SomeConnection(); > return new Employee(); > }finally { > sc.close(); > } Maybe, if "SomeConnection();" has an exception it will == 6 of 8 == Date: Fri, Oct 29 2004 4:42 pm From: "Tony Morris" <[EMAIL PROTECTED]> > Maybe, if "SomeConnection();" > has an exception it will > For every question asked, there's gotta be the Red Herring Award. You win. -- Tony Morris http://xdweb.net/~dibblego/ == 7 of 8 == Date: Fri, Oct 29 2004 7:01 pm From: "Brusque" <[EMAIL PROTECTED]> "Ann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Maybe, if "SomeConnection();" > has an exception it will > Liz I'm sure you're trying to be helpful, but wrong answers don't help anyone :( == 8 of 8 == Date: Sat, Oct 30 2004 2:10 am From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> "VisionSet" <[EMAIL PROTECTED]> writes: > I think scoping issues may be arguably left out of pseudocode. If it's pseudocode it's not Java, and as such we cannot answer because try/finally might do something other in that pseudocode language. IF the code was rewritten to actually compile, then the try block would execute in the example. ========================================================================== TOPIC: Homework - Was Re: java programe help http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fddd0a49ac12937 ========================================================================== == 1 of 1 == Date: Fri, Oct 29 2004 3:24 pm From: Joona I Palaste <[EMAIL PROTECTED]> Yogo <n o s p a m> scribbled the following on comp.lang.java.programmer: > "Alex Hunsley" wrote: >> One last thing Yogo: >> Your concerns would carry more weight if you were one of the people >> regularly helping people here. Being a regular, getting a feel for the >> group and actually helping others tends to put you in a better position to >> be criticising regular helpers. > I think you may be right, but, hey! I'm not a regular. Which doesn't mean I > am not allowed to say what I think... *Everyone* is allowed to say what they think. What Alex means is that being a regular helps towards people caring about what you think. Sorry to be so blunt, but it's the best way I could put it at this late hour. This doesn't mean this newsgroup is exclusively for old regulars, though. If you know what you're writing about, and mind your manners, you too might become a regular soon. -- /-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\ \-------------------------------------------------------- rules! --------/ "Outside of a dog, a book is a man's best friend. Inside a dog, it's too dark to read anyway." - Groucho Marx ========================================================================== TOPIC: Sinking in the JAVA quicksandbox http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c50f4e3273d0e1bb ========================================================================== == 1 of 1 == Date: Fri, Oct 29 2004 3:48 pm From: [EMAIL PROTECTED] (S J Rulison) [EMAIL PROTECTED] (Tim Jowers) wrote in message news:<[EMAIL PROTECTED]>... > Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > > On 28 Oct 2004 08:51:28 -0700, S J Rulison wrote: > > > > > A few days ago I posted a message .. > > > > Yes, I saw it.. > > <http://google.com/[EMAIL PROTECTED]> > > > > Why did you start a new thread? > > > > While we are on the subject, why did you give the new thread a > > silly name of "Sinking in the JAVA quicksandbox" (It's 'Java' BTW), > > rather than something useful and descriptive like 'Applet > > socket SecurityException'? > > > > And further, how did you go with the advice I gave you late in the thread.. > > <http://google.com/[EMAIL PROTECTED]> > > > > > ..I have recapped the crux of the situation below. > > > > Can you perhaps respond to my suggestions before you go > > calling for further help? It might save everybody time, > > and you from slipping beneath the quicksand.. ;-) > > > RJ, > > Andrew is correct. One the hot features of Java Applets was/is > sandboxing which means you cannot generally access the network or > filesystem from an applet. You can only access the server from which > you came to the browser and can access a scratch space on the disk > (sandbox). (This is why it works on your box but not when you try to > hit the server remotely.) Gotta sign that applet. > > You can do it for free but then your user has to accept the applet. > > TimJowers Okay Tim I'll look into it. Guess I'm going to have to hit Barns & Nobel tonight. Thanks for you help. ========================================================================== TOPIC: multiple forms and one servlet http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4dacdcfce2b3903e ========================================================================== == 1 of 2 == Date: Fri, Oct 29 2004 4:05 pm From: John Bickers <[EMAIL PROTECTED]> On Fri, 29 Oct 2004 14:23:02 -0700, Yasaswi Pulavarti wrote: > forms is pointing on one servlet. I want to process the different form > requests as different reponses in the same servlet. How can I do that > based on the form "Name" attribute. I don't think you can without picking up the form name and putting it into a different variable somehow, because it doesn't get sent on to the servlet when the form is submitted. However, you can add a hidden variable to the form's HTML, like a <input name="x" type="hidden" value="req1">, then in your doPost() method examine this variable to detect which request you're getting. == 2 of 2 == Date: Fri, Oct 29 2004 10:58 pm From: "Madhur Ahuja" <[EMAIL PROTECTED]> Yasaswi Pulavarti <[EMAIL PROTECTED]> wrote: > I have one servlet which has multiple forms. The action element of the > forms is pointing on one servlet. I want to process the different form > requests as different reponses in the same servlet. How can I do that > based on the form "Name" attribute. > Thanks, > Yasaswi You can do a post request and append a variable like this: <form method = post action = /servlet/process?pc1> <form method = post action = /servlet/process?pc2> Then, you write the code like this if(request.getQueryString.equals("pc1") { file://code for first form } else if (request.getQueryString.equals("pc2") { file://code for second form } else { // } -- Madhur Ahuja [madhur<underscore>ahuja<at>yahoo<dot>com] Homepage http://madhur.netfirms.com ========================================================================== TOPIC: regex: remove file ext http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9292732e966a520c ========================================================================== == 1 of 1 == Date: Fri, Oct 29 2004 3:13 pm From: Oscar kind <[EMAIL PROTECTED]> picaza <[EMAIL PROTECTED]> wrote: > i am trying to lope off the extention of filenames as i read them w/ a > regex. seems like it should be easy but i cant get the regex to work. > i would like to use "\\.\\w$" or "\\.\\S$" but they dont work. > what does work is > "\\...$" or "\\.nc$" > but these dont offer the flexibility i want. the snippet of code follows Try \..*$ in a String: "\\..*$". This matches a dot and anything that follows. You may also want to try "\\.[^.]*$", which only matches the last extension. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 ========================================================================== TOPIC: Possible HttpURLConnection.setFollowRedirects bug?I http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1f66b5ed7610a9b5 ========================================================================== == 1 of 2 == Date: Fri, Oct 29 2004 4:14 pm From: [EMAIL PROTECTED] (Wil Hadden) Hi, I have discovered a slightly obscure scenario that may cause a bug in HttpURLConnection and I was wondering if anyone could confirm it. With automatic redirection turned on, if I do a HTTP GET request, with various cookies set and I recieve a 302 redirect, HttpURLConnection will do the redirection but will not send on the cookies at the same time. I have confirmed that all browsers will send on the cookies. The net result is that the server will usually process the redirect differently due to the lack of cookies being sent to the new page. I am using the lastest 1.4 JRE. I may not be able to reply to this until Monday. Wil == 2 of 2 == Date: Fri, Oct 29 2004 4:21 pm From: "Brusque" <[EMAIL PROTECTED]> "Wil Hadden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I have discovered a slightly obscure scenario that may cause a bug in > HttpURLConnection and I was wondering if anyone could confirm it. > > With automatic redirection turned on, if I do a HTTP GET request, with > various cookies set and I recieve a 302 redirect, HttpURLConnection > will do the redirection but will not send on the cookies at the same > time. > > I have confirmed that all browsers will send on the cookies. The net > result is that the server will usually process the redirect > differently due to the lack of cookies being sent to the new page. > > I am using the lastest 1.4 JRE. > > I may not be able to reply to this until Monday. > > Wil HttpURLConnection doesn't do automatic cookie handling. It's only a very basic HTTP Client. Try using Commons HttpClient http://jakarta.apache.org/commons/httpclient/ ========================================================================== TOPIC: Help please - Why does ByteBuffer return '?' as opposed to what was put? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d3036bb0e4e92e4 ========================================================================== == 1 of 1 == Date: Fri, Oct 29 2004 5:05 pm From: [EMAIL PROTECTED] (Davis) "John C. Bollinger" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Ed wrote: > > > I have an annoying problem with ByteBuffer (BB). > > No, you have a lack of appreciation for the difference between bytes and > characters, and for the accompanying niceties of character encoding. > > > I have the following code: > > > > for (int i = 0; i < 255; i++) > > { > > ch = (char) i; > > test = new StringBuffer(); > > test.append((char) i); > > So far, so good. > > > byteBuffer.put(test.toString().getBytes()); > > But that's bad. You are using the no-arg version of String.getBytes(), > which encodes the characters of the string into an array of bytes > according to the system's default character encoding scheme. You should > _always_ use an explicit encoding scheme to (1) make your intention > clear and (2) ensure that your application works the same way on every > system. It will also get you thinking about what's happening; the > details of this conversion are part of what's tripping you up. > > > byteBuffer.flip(); > > > > back = byteBuffer.get(); > > That bit is probably fine, although you omitted the declaration of back. > > > // Uncomment below to see more working ... > > > > /* > > if (back < 0) > > { > > System.out.println("... adding 256 ...."); > > back = back + 256; > > } > > */ > > Well, yes, I can imagine that that might work better. byteBuffer.get() > returns a value of type *byte*, which is a *signed* 8-bit number. You > are comparing it (below) to a *char*, which (in one relevant sense) is > an *unsigned* 16-bit number. Try this: > > if (((char) 0x80) == ((byte) 0x80)) { > System.out.println("No duh!"); > } else { > System.out.println("Surprise!"); > } > > Note that, as for most numeric operations on bytes, chars, and shorts, > the operands are widened to type int, with sign extension, for that > comparison. > > > backch = (char) back; > > > > if (ch != backch) > > { > > System.out.println("ERROR - following do not match:"); > > } > > System.out.println("" + i + " [" + ch + "] = " + back + " [" + > > backch + "]"); > > byteBuffer.clear(); > > } > > > > The code works ok up to value 127. From 129 to 159 (hex 80 to 9F) > > bytebuffer always gives back the '?' char (int 63). From 160 to 255 I > > get a negative number. > > The '?' characters are a dead giveaway of a character encoding problem. > Your default character encoding is apparently a one-byte encoding > that does not map characters U+0080 through U+009f (and, probably not > characters greater than U+00ff, either). It is probably some variant on > Latin-1 (aka ISO/IEC 8859-1, which is not quite the same as ISO-8859-1), > which in fact doesn't define mappings for those characters, but which > also doesn't define mappings for characters U+0000 - U+0019. > > > I am obviously doing something wrong. > > You are improperly intermixing bytes and characters. Do not use > Strings, chars, StringBuffers, etc. to hold binary data. Binary data > that represents characters must be decoded according to the appropriate > character encoding scheme, and that scheme generally must be obtained > from an external source. Always specify the encoding explicitly when > producing binary representations of character data. > > And remember that Java bytes are signed. > > > John Bollinger > [EMAIL PROTECTED] You can find a utility class to convert a byte array to hex,short,int, or long Java primitives at http://www.sqlmagic.com/resources/UtilUnsigned.html. ========================================================================== TOPIC: why does ObjectInputStream constructor block reading a header http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7b8520ff9f293b96 ========================================================================== == 1 of 1 == Date: Fri, Oct 29 2004 8:05 pm From: [EMAIL PROTECTED] (kartik) The ObjectInputStream constructor blocks till it reads a header from the underlying input stream. This can cause deadlocks when you have a pair of object streams communicating over sockets (it has happened to me). Does anybody know why it may have been coded this way instead of reading the header on the first call to readObject()? -kartik ========================================================================== TOPIC: Setting up a filter based on server name http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/801866155eeb6057 ========================================================================== == 1 of 1 == Date: Fri, Oct 29 2004 6:44 pm From: Sudsy <[EMAIL PROTECTED]> freddiemac wrote: > What do you mean servers "tied to" an application? > HTTPServletRequest.getRequestURL() should give you what you need. > > MarkN wrote: > >> My situation is unique I guess. There are several virtual hosts tied >> to the same J2EE application (ColdFusionMX running on top of JRun4). I know what OP means: rather than creating a separate code base for each virtual host, they share a common one. A potentially disastrous approach, IMHO. -- Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development. ========================================================================== TOPIC: Student.HELP.Why does this code not compile? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1d7d030348369c72 ========================================================================== == 1 of 2 == Date: Fri, Oct 29 2004 8:16 pm From: "JavaMan" <[EMAIL PROTECTED]> public class Hw5 { public static void main(String[] args) { int x=10, y=12, z=8; System.out.println("The largest of " + x + ", " + y + " and " + z + " is: " + getLargest(x,y,z)); System.out.println("The average of " + x + ", " + y + " and " + z + " is: " + getAverage(x,y,z)); char c1='a', c2='b', c3='u'; System.out.println(c1 + " is a vowel: " + isVowel(c1)); System.out.println(c2 + " is a vowel: " + isVowel(c2)); System.out.println(c3 + " is a vowel: " + isVowel(c3)); String s1="hello", s2="madam"; System.out.println(s1 + " is a palindrome: " + isPalindrome(s1)); System.out.println(s2 + " is a palindrome: " + isPalindrome(s2)); System.out.println(s1 + ": has " + countVowels(s1) + "vowels"); System.out.println(s2 + ": has " + countVowels(s2) + "vowels"); } // write the getLargest method here that will receive 3 integers and return the largest of them // it starts like the following public static int getLargest(int a, int b, int c) { if (a >= b && a >= c) return a; else if (b >= a && b >= c) return b; return c; } } // write getAverage method here that will receive 3 integers and return the average of them // write isVowel method here that will receive a character and return "true" if it is vowel, return "false" otherwise // write isPalindrome method here that will receive a string and return "true" if it is a palindrome, return "false" otherwise // write countVowels method here that will receive a string and return the number of vowels in the string == 2 of 2 == Date: Fri, Oct 29 2004 8:41 pm From: [EMAIL PROTECTED] (Lee Weiner) In article <[EMAIL PROTECTED]>, "JavaMan" <[EMAIL PROTECTED]> wrote: >public class Hw5 >{ public static void main(String[] args) > >{ int x=10, y=12, z=8; >System.out.println("The largest of " + x + ", " + y + " and " + z + " is: " >+ getLargest(x,y,z)); >System.out.println("The average of " + x + ", " + y + " and " + z + " is: " >+ getAverage(x,y,z)); >char c1='a', c2='b', c3='u'; >System.out.println(c1 + " is a vowel: " + isVowel(c1)); >System.out.println(c2 + " is a vowel: " + isVowel(c2)); >System.out.println(c3 + " is a vowel: " + isVowel(c3)); >String s1="hello", s2="madam"; >System.out.println(s1 + " is a palindrome: " + isPalindrome(s1)); >System.out.println(s2 + " is a palindrome: " + isPalindrome(s2)); >System.out.println(s1 + ": has " + countVowels(s1) + "vowels"); >System.out.println(s2 + ": has " + countVowels(s2) + "vowels"); >} Because you haven't written the methods you call in main() ( getAverage, isVowel, isPalindrome, countVowels.) Comment out the code in main that calls those methods until you include them in your program. Lee Weiner lee AT leeweiner DOT org ========================================================================== TOPIC: MMS Protocol and JMF http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c858bbcbd26b2947 ========================================================================== == 1 of 1 == Date: Fri, Oct 29 2004 8:26 pm From: "Lee" <[EMAIL PROTECTED]> "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Thu, 28 Oct 2004 23:23:26 GMT, Lee wrote: > > (please trim text no longer relevant. keep our group lean) > > > "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message > .. > >> I think you are fighting an uphill battle to successfully use > >> a protocol for which the "rules of the protocol have not been > >> officially released" and is therefore seemingly open to change > >> at MS' whim. > ... > > I suppose you're right. But do think Microsoft would change mms a lot? > > Wouldn't it be a lot of hassle? > > When I wrote that I was actually thinking of Word docs.. > With every release, the format changes slightly, the same > seems the case for other formats. > > This *is* a hassle for the MS developers, and the users of MS > software, and the people who receive MS format documents, but also > for people who want to develop software that works with Word docs. > > Besides allowing MS to update/expand formats, I think the last reason > of 'keeping competitors at bay' is actually the main motivation for > 'updating' file formats. > > So, no, I don't think MS will change MMS *a* *lot*, but I have > no doubt they'd feel free to change it whenever the competitive > technologies/applications for reading the data are gaining > ground on the MS software. > > -- > 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 Good point. Cheers mate. I've looked in-depth at the packets sent to and fro when MMS:// is connected to via Windows media player. It appears that the whole protocol merely acts as a redirect to the RTSP port 554 and all data is pumped through 554 not 1755 (mms). All commands are in fact standardised RTP commands such as SETUP, PLAY, PAUSE and TEARDOWN. Anyway, it's an interesting area to study - especially as it's essentially a RTSP based protocol. ========================================================================== TOPIC: JavaScript or JavaApplet basic encryption suggestion http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/34c7bbef4bb229a8 ========================================================================== == 1 of 1 == Date: Fri, Oct 29 2004 9:18 pm From: [EMAIL PROTECTED] (Eli) Hi gurus, My question is about exchanging data on a basic HTML page between a JavaScript piece of code and a Java client-side <APPLET> residing on the same webpage. To demonstrate the idea of data encription at the client side to students my idea is to build a simple <FORM> on the webpage with 2 text fields and a submit button. The student fills in the text field on top and click Submit. At this moment, onsubmit() sends the text field value to the client side applet which scrambles the contents and returns the "encrypted" result to the webpage. The result should be shown on the HTML page, inside the bottom text field. The exchange question to you gurus is very basic: q1. What is the proper syntax in the JavaScript to call the applet's method myScramble(String theOriginalText)? q2. What is the proper syntax in the method above to "return" the result to the HTML page form field named TheEncryptedText? Thank you all for taking the time to read the description above. Kind regards, Eli ========================================================================== TOPIC: rules engines: faster implementation than methods invocations? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fe7838a641d72733 ========================================================================== == 1 of 1 == Date: Fri, Oct 29 2004 9:19 pm From: NOBODY <[EMAIL PROTECTED]> > You're benchmark is not very accurate. I've modified it so it actually > does some work and removed the object <-> primitive conversions. The > results using JDK 1.5 -server are: > > direct dolong: total=3205 ms, avg=0.080125 us, 440000000 > invoke dolong: total=4536 ms (1.4152886115444618x), avg=0.1134 us, > 440000000 > > So, the difference in speed is not as big as you suggest. > >[....] > public static Long dolong(Long l1, Long l2, String s1, String s2) { > return new Long(l1.longValue() + l2.longValue() + s1.length() + > s2.length()); > } > } My test was fine, accurate and thought through. You just threw all mesurements off... Here's why in 3 reasons: 1--- you are measuring the time of the behavior of the method, not the method call. You suggest that the overhead would be negligible if the body was working more. True. But I wanted to compare the cost of calls, because for a rule engine, the operations are often very short. Rules can be as simple as 1 single equality '==' operation. Even with: public static long dolong(long l1, long l2, String s1, String s2) { return l1+l2+s1.length()+s2.length(); } I get 35x: direct dolong: total=62 ms, avg=0.0062 us invoke dolong: total=2016 ms (32.516129032258064x), avg=0.2016 us 2--- you force the memory trashing (with Long wrapper) that I explicitely wanted to avoid. I DO want to use primitive, for obvious speed gain. I know reflection wraps/unwraps. I actually took the time to write the args array only once to avoid that wrapping overhead, and limit the extra invocation work to unwrapping. It is not my choice if reflection api is too limited to handle primitive. So it is part of the cost of invocation, which is the purpose of the test. 3--- You introduced an extra sum and .longValue in the for loop, screwing the timing again by adding behavior time instead of constraining the test to method call time. ********** So, back to the question: ********** Are there rules engine implementations not relying on method invocation (compiled code, I guess)? ========================================================================== TOPIC: help with internationalization/localization http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b2947dc6ffc5f377 ========================================================================== == 1 of 2 == Date: Fri, Oct 29 2004 10:09 pm From: Praveen <[EMAIL PROTECTED]> Hi...All, I was trying an example as per the java.sun.com website for internationlization & localization. The example worked fine. Now I am having some problem with the chinese characters. Here are the steps I followed, 1. Went to google & searched for "database table" http://www.google.com/search?hl=zh-TW&q=database+table&btnG=%E6%90%9C%E5%B0%8B&lr=lang_zh-TW 2. Saved the page locally & stripped all characters except for the one which says 'database' . (of course with help of my chinese friend) 3. renamed the file to the resource bundle Message_zh_TW.properties with one entry Database = 資料庫 4. But once I run the test by creating a new locale("zh", "TW") & try to get the string "Database", it prints ??? If I read this file from a browser directly file://c:/<file name> it displays the character correctly. How do I fix it? Regards, P == 2 of 2 == Date: Sat, Oct 30 2004 12:13 am From: Lāʻie Techie <[EMAIL PROTECTED]> On Sat, 30 Oct 2004 05:09:27 +0000, Praveen wrote: > 3. renamed the file to the resource bundle Message_zh_TW.properties with > one entry > Database = 資料庫 You should escape the unicode characters. > > 4. But once I run the test by creating a new locale("zh", "TW") & try to > get the string "Database", it prints ??? Prints where and how? A question mark generally states that particular character is not defined in the current font and/or codepage. > If I read this file from a browser directly file://c:/<file name> it > displays the character correctly. Read it how? In a browser? In a UTF-8 aware text editor? "Type"ing it on the command prompt? HTH, La'ie Techie ========================================================================== TOPIC: SOAP and servlets living together? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2dca87f4c115f04c ========================================================================== == 1 of 1 == Date: Sat, Oct 30 2004 1:01 am From: [EMAIL PROTECTED] (unixhack.blogspot.com) [EMAIL PROTECTED] (unixhack.blogspot.com) wrote in message news:<[EMAIL PROTECTED]>... > I'm trying to develop an application that uses SOAP and servlets. > So far I have some servlets and JSP's running fine. They access > the database, modify it, display data, etc. Thanks everybody for the responses! -- E ======================================================================= 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
