comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * please recommend a design pattern book in java - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/99dfc42b6357856 * [REPOST] java.awt.Image problem - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7f984034b7d7f294 * Something is wrong with "Casting" - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c2bd1fad596dfdf8 * Correct Semaphore Implementation in Java - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8259aec1ceed4f8f * JVM shut down ala Eclipse or Jbuilder - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4bc2493416cd4232 * Best way to do this - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e38d69ac964c0ee * My understanding in "new" keyword - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/62e90e8bce4915a9 * adding jars to classpath on runtime without -cp option - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e98c253d97fad483 * Sending mail - Created By field contains junk information - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f36d7268525953f7 * Unable to have tags within tags?? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d0b216afc2658f5c * Validation of string extension and editing documents - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6b4d7de5ad5ae04c * validation of document extension - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5096ebe0be27ad01 * console editor - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9a72ea0e72037234 * Synchronized block is accessed by other jsps - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e19df43edcc6f04f * How do start the Macintosh mail client? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2f14edf4c5379aff * Why cannot open .txt file with Encoding = UNICODE using javascript window.open()? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/14899a162cf7e7f8 * Function not visible outside the NetBeans IDE - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eb7dc4327dd3b738 * struts - opening new sized window - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5323c441b16e075b * ConnectionLess or ConnectionOriented ResultSet - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6c64486958c9e834 * Help with lexical events and a TransformerHandler - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8db599f52feb1dc2 ============================================================================== TOPIC: please recommend a design pattern book in java http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/99dfc42b6357856 ============================================================================== == 1 of 2 == Date: Tues, Nov 30 2004 12:01 pm From: [EMAIL PROTECTED] In article <[EMAIL PROTECTED]>, Ann <[EMAIL PROTECTED]> wrote: > >"metfan" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >> I searched Amazon and it came out a list, could you please recommend one, >which one is of the best for a mid-level programmer? Thanks. >> >> 1) Design Patterns Java Workbook by Steven John Metsker >> 2) Applied Java Patterns by Stephen A. Stelting >> 3) Java Design Patterns: A Tutorial by James William Cooper >> 4) Patterns in Java: A Catalog of Reusable Design Patterns Illustrated >with UML, 2nd Edition, Volume 1 by Mark Grand >> 5) Java Design: Objects, UML, and Process by Kirk Knoernschild >> 6) Object-Oriented Software Engineering: Using UML, Patterns and Java, >Second Edition by Bernd Bruegge >> 7) Software Architecture Design Patterns in Java by Partha Kuchana > >Two general techniques: >1. look in your library and assume they order the good books >2. look for a book that is less than 1 year old Technique #2 seems a bit suspect, as it would seem to argue against, for example, the three volumes (so far) of Knuth. (Yes, there's a valid point to be made about choosing the newer book when there are several choices that are otherwise equal. But how often that's the case .... ) -- | B. L. Massingill | ObDisclaimer: I don't speak for my employers; they return the favor. == 2 of 2 == Date: Tues, Nov 30 2004 3:34 pm From: Thomas Weidenfeller [EMAIL PROTECTED] wrote: >Thomas Weidenfeller wrote: >> >>Gamma, Helm, Johnson, Vlissides: Design Patterns. Elements of Reusable >>Object-Oriented Software. > > > Because it's very abstract and hard to understand, imho. Are you serious? /Thomas -- ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq ============================================================================== TOPIC: [REPOST] java.awt.Image problem http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7f984034b7d7f294 ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 4:02 am From: "MaSTeR" > The best way to get someone to spot your error (or for you yourselves to > realize what you're doing wrong) is to post a short code sample that > exhibits the problem. Redisplaying from a double buffer does work - even > on the Sun VM - and if it isn't, it is most certainly something wrong > that you're doing in the code. (To take a wild guess - it could be that > your drawImage call passes a null as the ImageObserver ?). > > BK > Right, unfortunately the code is almost 3 thousands line, I'll try to summarize it. /* * Forces repaint of the ticker */ public void paint(Graphics g) { if (offScreenImage == null) offScreenImage = createImage(this.getBounds().width, this.getBounds().height + rowHeight); // I need a template to paint something if (template == null) return; slideLeft(g); // THIS JUST REDRAW THE BUFFER } private void slideLeft(Graphics g) { int drawAtPosition = drawHorizontalAt+distance+scrollingOffset; g.drawImage(offScreenImage, drawAtPosition, 0, this); } When a new record comes in: synchronized(this) { if (effectInProgress) { killPaintingThread = true; try { wait(); } catch(InterruptedException e) { System.out.println("Couldn't wait on the painting thread."); } } repainter = new Thread(this); repainter.setPriority(Thread.MIN_PRIORITY); repainter.setName("Painter"); // Notify the object that a new element is inserted newElementInserted = true; killPaintingThread = false; paintHorizontal(getGraphics(), true); repainter.start(); } Pretty much I repaint the buffer and redisplay or start a thread to scroll it (to simulate insertion) As you see I am calling drawImage with this as observer. Thanks for the help ! ============================================================================== TOPIC: Something is wrong with "Casting" http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c2bd1fad596dfdf8 ============================================================================== == 1 of 2 == Date: Tues, Nov 30 2004 12:05 pm From: "MaSTeR" "Patricia Klimek" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hey, > > the Problem I have is kind of crazy: > I want to cast a vector to Integer and save elementAt(1) in Integer i: > > Integer i = (Integer)row.elementAt(1); > > It does show me the Element if I do this: > System.out.println(row.elementAt(1)); > but if I cast it, it's not working. > > System.out.println(row.elementAt(1)); --- is working > Integer id = (Integer)row.elementAt(1); --- is not working > because of the casting > System.out.println("id: " + row.elementAt(1)); --- is not working > Human human = new Human(id); --- is not working > > > I probably can't cast the Vector element, right? > But how can I do it? > > I hope somebody can help me. > > Please > > Patricia You do know that any collection in Java is zero based ? == 2 of 2 == Date: Tues, Nov 30 2004 9:24 am From: "John C. Bollinger" Patricia Klimek wrote: > the Problem I have is kind of crazy: > I want to cast a vector to Integer and save elementAt(1) in Integer i: You cannot cast a Vector to Integer. It isn't one. If some element of the vector is an Integer then you can cast that; that is what your first line of code below attempts to do: > Integer i = (Integer)row.elementAt(1); The method invocation operator (.) has precedence over the typecast, so it happens first and you are attempting to cast the return value from type Object to type Integer. That will succeed of the element is an Integer or if it is null. > It does show me the Element if I do this: > System.out.println(row.elementAt(1)); > but if I cast it, it's not working. The only reason a cast ever fails is that the class of the object being cast is incompatible with the type it is being cast to. In that case a ClassCastException is thrown. If you are not getting a ClassCastException then the cast is not your problem; if you _are_ getting one then the problem is that the object you are trying to cast is not an Integer. Do make sure you understand that Java typecasts do not *change* the class of an object -- they simply declare it to be a certain type (or a subtype) in a way that can be checked at runtime. That means, for instance, that no String can be successfully cast to Integer, even one that contains a representation of a number (e.g. "42"). For that particular case you need to create an Integer by means of Integer.valueOf(String), or possibly to obtain an int (primitive) value by means of Integer.parseInt(String). John Bollinger [EMAIL PROTECTED] ============================================================================== TOPIC: Correct Semaphore Implementation in Java http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8259aec1ceed4f8f ============================================================================== == 1 of 3 == Date: Tues, Nov 30 2004 1:13 pm From: Andrea Desole [EMAIL PROTECTED] wrote: > > Yes, you can't tell from this invariant who's doing the P and V > operations. I guess I don't think of that as vitally important > information. I'm not sure. The point is that in the real world, when people are misusing (more or less unintentionally) your code and your resources, it's fair to put a check to preserve the integrity of whatever you are managing. It's not really vitally important, but it helps. > Okay, I'm clearer on what you meant. I don't think of the two > situations as sufficiently different to merit different types of > semaphores. Maybe others think differently. In fact the idea of > thinking of P as "request resource" and V as "release resource" is > somewhat new to me, though now that it's been mentioned, it makes > a kind of sense. And I think it can apply to both situations, > with the caveat that maybe in the producer/consumer case it should > be "consume a resource" and "create a resource". > > Maybe it's worth mentioning that my perspective on all of this stuff > is somewhat theory-oriented; I first learned about semaphores in a > very theory-minded course on concurrent algorithms, and they were > presented as an abstract mechanism that we used to write paper-only > algorithms about which we proved things. As a former math major, > I found it all good fun -- but I think it was also useful as a way > of getting the key points without a lot of implementation clutter. > YMMV, maybe. > Yes, I noticed a theory oriented attitude. Nothing to say, I like it. I actually learned semaphores in the same theoretical way. It's just that some practical issues should also be considered. At least I would, in this case. == 2 of 3 == Date: Tues, Nov 30 2004 12:41 pm From: [EMAIL PROTECTED] In article <[EMAIL PROTECTED]>, Andrea Desole <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] wrote: > >> >> Yes, you can't tell from this invariant who's doing the P and V >> operations. I guess I don't think of that as vitally important >> information. > >I'm not sure. The point is that in the real world, when people are >misusing (more or less unintentionally) your code and your resources, >it's fair to put a check to preserve the integrity of whatever you are >managing. It's not really vitally important, but it helps. True, but .... Can you give an example of how you'd do this in practice? Nothing's occurring to me at the moment. [ snip ] >> Maybe it's worth mentioning that my perspective on all of this stuff >> is somewhat theory-oriented; I first learned about semaphores in a >> very theory-minded course on concurrent algorithms, and they were >> presented as an abstract mechanism that we used to write paper-only >> algorithms about which we proved things. As a former math major, >> I found it all good fun -- but I think it was also useful as a way >> of getting the key points without a lot of implementation clutter. >> YMMV, maybe. >> > >Yes, I noticed a theory oriented attitude. Oh right, I guess the word "invariant" was a tip-off .... :-)? [ snip ] -- | B. L. Massingill | ObDisclaimer: I don't speak for my employers; they return the favor. == 3 of 3 == Date: Tues, Nov 30 2004 2:37 pm From: Andrea Desole > > True, but .... Can you give an example of how you'd do this in > practice? Nothing's occurring to me at the moment. I think it should be possible to build a map or a collection of threads that acquire a lock (maybe using the thread name). If the thread is in the collection it can release the lock, otherwise it can't > > > Oh right, I guess the word "invariant" was a tip-off .... :-)? :-) Also the reference to the producer/consumer problem, which I've seen only on books. This also made me think of a computer science student. The invariant made me think more of a theory-oriented developer. ============================================================================== TOPIC: JVM shut down ala Eclipse or Jbuilder http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4bc2493416cd4232 ============================================================================== == 1 of 2 == Date: Tues, Nov 30 2004 4:14 am From: John English Sambucus wrote: > Ehh, yes of course, but that will not work for me I'm afraid. > I dont know if eclipse/jbuilder uses a native call to end the jvm > process? In that case it would be the same as using the task manager, > but can you implement that into a Java app? Try Runtime.exit() -- "terminates the currently running Java virtual machine by initiating its shutdown sequence". ----------------------------------------------------------------- John English | mailto:[EMAIL PROTECTED] Senior Lecturer | http://www.it.bton.ac.uk/staff/je School of Computing & MIS | ** NON-PROFIT CD FOR CS STUDENTS ** University of Brighton | -- see http://burks.bton.ac.uk ----------------------------------------------------------------- == 2 of 2 == Date: Tues, Nov 30 2004 12:30 pm From: Andrew Thompson On Tue, 30 Nov 2004 12:14:29 +0000, John English wrote: > Sambucus wrote: > >> Ehh, yes of course, but that will not work for me I'm afraid. >> I dont know if eclipse/jbuilder uses a native call to end the jvm >> process? In that case it would be the same as using the task manager, >> but can you implement that into a Java app? > > Try Runtime.exit() -- "terminates the currently running Java virtual > machine by initiating its shutdown sequence". Which, according to the JavaDocs "The System.exit method is the conventional and convenient means of invoking this method" The OP mentioned earlier that invoking System.exit() was (amongst) the current way of doing things. [ Follow-Ups set to c.l.j.help. ] -- 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: Best way to do this http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e38d69ac964c0ee ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 4:17 am From: [EMAIL PROTECTED] (Fran Garcia) I have tested to do the jSlider as static. I know that isn´t the better solution, but I have tested and I noticed that the effect doesnt´s semm well. I wanna make every second, update the jslider with the information from the class that plays the wav file. Do you understand me? Something like: every second do{ update_jSlider(ClassPlay(getFramePosition)); } How do you see it? Thanks Fran García Chris Smith <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Fran Garcia <[EMAIL PROTECTED]> wrote: > > This is the code for the creation of the class to playing the wav > > file. > > Okay, so you're doing playback with the javax.sound.sampled.* package. > That's good, and makes things a lot easier. Now you just need to > communicate your position to the the JSlider. Somewhere, do you have a > loop that looks something like this? > > byte[] buffer = new byte[BUF_SIZE]; > int len; > while ((len = m_flujoEntradaAudio.read(buffer)) != -1) > { > m_line.write(buffer, 0, len); > } > > If so, then you just need to add code inside that loop to update the > JSlider position. ============================================================================== TOPIC: My understanding in "new" keyword http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/62e90e8bce4915a9 ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 1:19 pm From: Michael Borgwardt VisionSet wrote: > However, note that this is peculiar to Strings and typically objects are > only created with the new keyword. Or through clone(). Or through Deserialization. ============================================================================== TOPIC: adding jars to classpath on runtime without -cp option http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e98c253d97fad483 ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 5:00 am From: [EMAIL PROTECTED] (rony) "Ferenc Hechler" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Hi Rony, > > thats exactly what the Class "ClassPathHacker" is doing, > Perhaps you should look at the thread > http://forum.java.sun.com/thread.jspa?threadID=300557&start=0&tstart=0 > again. > There are two solutions mentioned. > One using reflections to access the protected method addURL of ClassLoader > and the other changing the Thread-Context ClassLoader using > Thread.currentThread().setContextClassLoader . > > bye, > > feri > > > "rony" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > news:[EMAIL PROTECTED] > > "Ferenc Hechler" <[EMAIL PROTECTED]> wrote in message > > news:<[EMAIL PROTECTED]>... > >> You can use URLClassLoader to do the class-loading. > >> Take a look at the following thread: > >> http://forum.java.sun.com/thread.jspa?threadID=300557&start=15&tstart=0 > >> > >> bye, feri > > > > Hi, > > > > The problem is that I don't know the name of the class that is going > > to be used. I just know that jar where it is located. I want the VM to > > look there. > > > > Thanks, > > Rony Hi, an answer at last. thanks a lot feri. ============================================================================== TOPIC: Sending mail - Created By field contains junk information http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f36d7268525953f7 ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 2:08 pm From: "Jack Andersson" Here you have it! import java.util.*; import java.lang.*; import java.net.InetAddress; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class MailTST { public static void main(String[] args) throws Exception { Properties props = new Properties(); props = System.getProperties(); props.put("mail.smtp.host", "mail.OurCompanyDomain.com"); Session session = Session.getDefaultInstance(props, null); session.setDebug(true); // Debug mode is activated // create a message MimeMessage msg = new MimeMessage(session); String sFrom = "[EMAIL PROTECTED]"; String sTo = "[EMAIL PROTECTED]"; String sSubject = "Mailtest with java."; String sMessage = "Bla bla bla ..."; String sFileName = null; InternetAddress reply[] = new InternetAddress[1]; reply[0] = new InternetAddress("[EMAIL PROTECTED]"); String test = InetAddress.getLocalHost().getHostName(); msg.setFrom(new InternetAddress(sFrom)); msg.setSender(new InternetAddress("[EMAIL PROTECTED]")); msg.setReplyTo(reply); msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(sTo, false)); msg.setSubject(sSubject,"ISO-8859-1"); msg.setSentDate(new Date()); // create and fill the first message part MimeBodyPart mbp1 = new MimeBodyPart(); mbp1.setText(sMessage,"ISO-8859-1"); // create the Multipart and add the first path Multipart mp = new MimeMultipart(); mp.addBodyPart(mbp1); // create the second message part if file should be attached if (sFileName != null) { int nStart = 0; int nSlut = 0; String sTmp1 = ""; nStart = sFileName.indexOf(' ', nStart); nSlut = sFileName.indexOf(' ', nStart); if ( nStart >= 0 ) { sTmp1 = sFileName.substring(0, sFileName.indexOf(' ', nStart)); MimeBodyPart mbp2 = new MimeBodyPart(); // attach the file to the message FileDataSource fds = new FileDataSource(sTmp1); mbp2.setDataHandler(new DataHandler(fds)); mbp2.setFileName(fds.getName()); mp.addBodyPart(mbp2); while ( nStart <= sFileName.lastIndexOf(' ') ) { nStart = sFileName.indexOf(' ', nStart); if ( nStart < 0 ) { break; } nSlut = sFileName.indexOf(' ', nStart + 1); if ( nSlut < 1 ) nSlut = sFileName.length(); sTmp1 = sFileName.substring(nStart + 1, nSlut); MimeBodyPart mbp3 = new MimeBodyPart(); // attach the file to the message FileDataSource fds3 = new FileDataSource(sTmp1); mbp3.setDataHandler(new DataHandler(fds3)); mbp3.setFileName(fds3.getName()); mp.addBodyPart(mbp3); nStart = nSlut; } } else { sTmp1 = sFileName; MimeBodyPart mbp2 = new MimeBodyPart(); // attach the file to the message FileDataSource fds = new FileDataSource(sTmp1); mbp2.setDataHandler(new DataHandler(fds)); mbp2.setFileName(fds.getName()); mp.addBodyPart(mbp2); } } // add the Multipart to the message msg.setContent(mp); Transport.send(msg); } } ============================================================================== TOPIC: Unable to have tags within tags?? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d0b216afc2658f5c ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 5:20 am From: [EMAIL PROTECTED] (Kwasi) I'm using WSAD version 5.1 Chris Smith <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Kwasi <[EMAIL PROTECTED]> wrote: > > Chris, Thanks for the response.. > > Unfortunately, I'm using JSP 1.2 so this is at compile time (The > > development tool is giving me problems). I'm not using any exotic > > validators with my JSP. > > The question is the same: which development tool is giving you problems? > "The" development tool isn't very descriptive. There are literally tens > of thousands of development tools in the world, and at least hundreds > that are relevant to what you're doing. > > > I did have a typo in my snipet, It should read: > > <input type="hidden" name="domainName" value="<c:out > > value={requestScope.domainNm}>"/> > > Well, actually it should read: > > <input type="hidden" name="domainName" value="<c:out > value="${requestScope.domainNm}"/>"/> > > So perhaps that's your problem? ============================================================================== TOPIC: Validation of string extension and editing documents http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6b4d7de5ad5ae04c ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 5:32 am From: [EMAIL PROTECTED] (Roy) Hello I have look at this site for some time now getting tidbits of information and knowledge from the people here, I am new to programming literally, my background is business but I have been thrust into java since July. It has been a very unique experience with only two weeks of training *S* I have a task where I am trying to validate a file extension to make sure it is valid.The extension would either be xls, doc, text, ppt, online/webform and pdf. Here is the code I have been working with if anyone has any ideas please help me. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <jsp:useBean id="db" scope="request" class="com.kdoc.beans.DBConnectionInfo"/> <%@ taglib uri= "../WEB-INF/c.tld" prefix="c"%> <%@ taglib uri= "../WEB-INF/taglib48.tld" prefix="dbt" %> <%//<c:set var="Doc" value="${param.Doc}" /> //<c:if test="${!empty Doc}"><c:redirect url="${Doc}"/></c:if> %> <% String DocName=""; if(request.getParameter("DocName")!=null) { DocName = (String)request.getParameter("DocName"); } String TITLE=""; if(request.getParameter("DOC_TITLE")!=null) { TITLE = (String)request.getParameter("DOC_TITLE"); } String[] rType = {".xls", ".doc", ".txt", ".pdf", ".ppt"}; %> <dbt:openConnection driver="<%= db.getDbDriverName() %>" url="<%= db.getDbUrl() %>" user="<%= db.getDbUser() %>" password="<%= db.getDbPassword() %>" id="A"/> <dbt:setQuery id="A" res="rsCatDOC"> <dbt:setSQL>SELECT (CCAT_ID), rtrim(CCAT_TITLE), CCAT_RANK from OLAPPS.WIA_CCAT</dbt:setSQL> </dbt:setQuery > <dbt:openConnection driver="<%= db.getDbDriverName() %>" url="<%= db.getDbUrl() %>" user="<%= db.getDbUser() %>" password="<%= db.getDbPassword() %>" id="B"/> <dbt:setQuery id="B" res="rsDOC"> <dbt:setSQL>SELECT (DOC_ID), rtrim(DOC_TITLE), DOC_RANK from COREWEB.CORE_DOCS</dbt:setSQL> </dbt:setQuery > <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>WIADOCS</title> </head> <body> <form action="<%= request.getRequestURI() %>" method="get" enctype="multipart/form-data" class="formstyle" > <select name="CatDoc" class="formselectbox" size="1" id="CatDoc" > <dbt:forEachRow res="rsCatDOC"> <dbt:getColumn res="rsCatDOC" position="1" id="CCAT_ID" /> <dbt:getColumn res="rsCatDOC" position="2" id="CCAT_TITLE" /> <option value="<%=CCAT_ID %>"><%=CCAT_TITLE %></option> </dbt:forEachRow></select> <select name="Doc" class="formselectbox" size="1" id="Doc"> <dbt:forEachRow res="rsDOC"> <dbt:getColumn res="rsDOC" position="1" id="DOC_ID" /> <dbt:getColumn res="rsDOC" position="2" id="DOC_TITLE" /> <option value="<%=DOC_ID %>"><%=DOC_TITLE %></option> </dbt:forEachRow> </select> <input name="Submit" type="submit" id="submit" value="Submit" /> <label>Document input field:</label><br> <input type="text" name="DocName"> </form> <%=DocName %><%=TITLE %> </body> </html> <dbt:closeConnection id="A"/> <dbt:closeConnection id="B"/> ============================================================================== TOPIC: validation of document extension http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5096ebe0be27ad01 ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 5:43 am From: [EMAIL PROTECTED] (Roy) Hello I have been watching and learning from this newsgroup ever since I started learning java which was four months ago, I don't have a programmers background and this is really new and exciting to me. I am trying to write a jsp page that when a user wants to put a document, file in the database the page will verify that the extension on the file is correct, believe me some people don't really know how to upload files correctly *S*, I am stuck at the point of trying to get the page to recognize the document, for instance the extenstion would either be xls,doc,ppt, pdf, txt, or online/webform. Here is part of the code I have been working with. <% String DocName=""; if(request.getParameter("DocName")!=null) { DocName = (String)request.getParameter("DocName"); } String TITLE=""; if(request.getParameter("DOC_TITLE")!=null) { TITLE = (String)request.getParameter("DOC_TITLE"); } String[] rType = {".xls", ".doc", ".txt", ".pdf", ".ppt"}; %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>WIADOCS</title> </head> <body> <form action="<%= request.getRequestURI() %>" method="get" enctype="multipart/form-data" class="formstyle" > <select name="CatDoc" class="formselectbox" size="1" id="CatDoc" > <dbt:forEachRow res="rsCatDOC"> <dbt:getColumn res="rsCatDOC" position="1" id="CCAT_ID" /> <dbt:getColumn res="rsCatDOC" position="2" id="CCAT_TITLE" /> <option value="<%=CCAT_ID %>"><%=CCAT_TITLE %></option> </dbt:forEachRow></select> <select name="Doc" class="formselectbox" size="1" id="Doc"> <dbt:forEachRow res="rsDOC"> <dbt:getColumn res="rsDOC" position="1" id="DOC_ID" /> <dbt:getColumn res="rsDOC" position="2" id="DOC_TITLE" /> <option value="<%=DOC_ID %>"><%=DOC_TITLE %></option> </dbt:forEachRow> </select> <input name="Submit" type="submit" id="submit" value="Submit" /> <label>Document input field:</label><br> <input type="text" name="DocName"> </form> <%=DocName %><%=TITLE %> </body> </html> <dbt:closeConnection id="A"/> <dbt:closeConnection id="B"/> If anyone can help me please offer your input, some of the code has been omitted for security purpose. Thanks. ============================================================================== TOPIC: console editor http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9a72ea0e72037234 ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 9:00 am From: Jim Sculley karl wettin wrote: > Daniel Sjöblom wrote: > >> karl wettin wrote: >> >>> Hello group, >>> >>> I want to write a console editor (nano, pico, vi, et.c.) in java, but >>> have no clue where to start. All hints are welcome. Maybe there is a >>> project I could base it on? >> >> >> >> There is no support for console manipulation in standard java. There >> are some third party libraries though, do a google search for "curses >> for java" without the quotes. > > > Excellet, thanks! > > <http://sourceforge.net/projects/javacurses/> is my selection for now. > >> I'm not aware of any console editors written in java, but you may want >> to take a look at Jext and Jedit for some general ideas. Before you >> embark on this project you should really ask yourself if the world >> needs yet another editor and if java is really the language you want >> to write this in. Other than that, I only wish you good luck! > > > I want to write a native java IDE for my console :) You could write it in Swing, and then convert it for console use via Charva. http://www.pitman.co.za/projects/charva/ Jim S. ============================================================================== TOPIC: Synchronized block is accessed by other jsps http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e19df43edcc6f04f ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 9:05 am From: "John C. Bollinger" biswa wrote: > I have the synchronized block in my class file > public class MyClass { > > public synchronized boolean myFunc() { > > //--> Table created > //--> Table accessed > //--> Table dropped > } > } > > I am calling this method in the JSP file > This is my code in jsp file. > <% > MyClass myClass = new MyClass(); > //.. some codes here > > if(myClass.myFunc()) > //do something > else > //do something > > //-- some codes here. > %> > > myClass.myFunc() is accessed by more than one request at same time > although the method is synchronized in the java file. I do not > understand why. As others wrote already, the method is being invoked concurrently on _different instances_ of your class. The method is synchronized on "this", so synchronization does not prevent that. To get synchronization working as you hope, you need all instances to synchronize on a common object. You can achieve that by making the method static (and still synchronized) if that is feasible, or by providing a static member that myFunc() synchronizes on. (E.g.: public class MyClass { private final static Object MY_FUNC_LOCK = new Object(); [...] public boolean myFunc() { synchronized(MY_FUNC_LOCK) { [...] } } } ) > But to test I kept the method in a synchronzied block within Jsp file > and i do not see two requests accessing myFunc() any more. > new code looks like this > <% > MyClass myClass = new MyClass(); > //.. some codes here > > synchronized(this) { > if(myClass.myFunc()) > //do something > else > //do something > } > //-- some codes here. > %> That will work only as long as nothing else (no other page, no third object, etc) tries to invoke MyClass.myFunc(). It is a kluge, not a solution. > Is the 2nd method correct way of synchronizing a method to access in > JSP file?? if so i have to change all my JSP files :(( No, it isn't. See above. But better by far than getting synchronization right is to avoid the need for synchronization in the first place. In your example it ought to be possible to write MyClass.myFunc() so that concurrent execution is possible, since it does not make any persistent changes to application state. That is what I recommended to you in the first place. John Bollinger [EMAIL PROTECTED] ============================================================================== TOPIC: How do start the Macintosh mail client? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2f14edf4c5379aff ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 2:09 pm From: [EMAIL PROTECTED] Does anybody know how to start the Macintosh system's standard mail client from within a Java program? I want to create and send a mail through this client, and for certain reasons cannot use the JavaMail API. Thanks for any hints, Bernd -- Bernd Eggink Regionales Rechenzentrum der Uni Hamburg [EMAIL PROTECTED] http://www.rrz.uni-hamburg.de/RRZ/B.Eggink/ ============================================================================== TOPIC: Why cannot open .txt file with Encoding = UNICODE using javascript window.open()? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/14899a162cf7e7f8 ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 9:10 am From: "John C. Bollinger" ml wrote: > I cannot directly open the text file with Encoding = UNICODE using the > javascript window.open() method, do anyone know why?? comp.lang.javascript is just down the hall. On your way there, you might want to contemplate the fact that Unicode is not a character encoding in the same sense that UTF-8 or ISO-8859-1 is. I don't know enough about Javascript to be able to tell you what Encoding=UNICODE would mean, if it is meaningful at all. John Bollinger [EMAIL PROTECTED] ============================================================================== TOPIC: Function not visible outside the NetBeans IDE http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eb7dc4327dd3b738 ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 6:43 am From: [EMAIL PROTECTED] (Rick T.) Hi: I wrote a GUI application using NetBeans IDE 3.6 and J2SDK1.4.2_05 which worked out really well within the NetBeans IDE environment. But when I try to run it from the commandline or a desktop icon, the GUI comes up but one of the methods I'm calling from another class claims to be non-existent. The class I'm referencing is public and so is the method I'm invoking. Can anyone tell me how this is possible? My CLASSPATH is set up to point to the directory where all of my classes are --including the one I'm having a problem with. I appreciate any advice you may have! Thanks! Rick T. DRS Comm ============================================================================== TOPIC: struts - opening new sized window http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5323c441b16e075b ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 7:01 am From: [EMAIL PROTECTED] (Brock Heinz) Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > On 29 Nov 2004 12:33:08 -0800, Raycaster wrote: > > > Using Struts, I have a form displayed for a user to edit values. Now > > next to a text area, I have a label which is a link that opens a new > > window that displays a grid of available values for the text box. The > > user clicks on a value and the popup window closes and fills in the > > parent window with the selected value. This all works fine, but I want > > to do is open the popup window with a specific size ( using javascript, > > you specify the width and height ). I am lost at how to do this. > > Good. Don't do it. > > Unless you can also get lots of cash from refactoring it back to > a single window app. later when the clients realise that half > their customers who just installed IE SP2, the Google ToolBar, > another browser with pop-up blockers (read most released within > last 12 months) etcetera cannot use the application. Without asking anything concerning the requirements - this: 'Good. Don't do it.' is a bit harsh. True, most browsers will now block popups. But with intranet applications, coding an applictation in this manner is certainly acceptable. Now although this isn't a 'java' issue, your requirement can be accomplished using Javascript: <html> <head> <script type="text/javascript"> function openwindow(ipt) { window.open(ipt,"new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=yes, width=400, height=400,top=0,left=0"); } </script> <body> <a href="javascript:openwindow('http://www.google.com')">Open!</a> </body> </html> Brock ============================================================================== TOPIC: ConnectionLess or ConnectionOriented ResultSet http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6c64486958c9e834 ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 7:05 am From: [EMAIL PROTECTED] (indo3) Hello, In JDBC, ResultSet represents a select-result-table from a select-sql-statement to a database. Question: does ResultSet need an active connection to the database or is the contents "offline"? In .NET, there are two approaches: IDataReader for fetching the next result online, or DataSet for fetching all content and then going offline if one like. Dont know where to put ResultSet, any idea? THANKS ============================================================================== TOPIC: Help with lexical events and a TransformerHandler http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8db599f52feb1dc2 ============================================================================== == 1 of 1 == Date: Tues, Nov 30 2004 7:05 am From: Collin VanDyck Hello! I have set up a pluggable SAX transformation pipeline which is made up of individual nodes that transform the source XML, and for the most part it works well. Each node in the pipeline is assigned a ContentHandler and a LexicalHandler by the transformation framework. Each node in the pipeline may either be: * a class that implements ContentHandler and LexicalHandler * a wrapper class that creates a TransformerHandler from an XSL stylesheet and handles the SAX events. The first case works perfectly. Both normal and lexical SAX events are processed and then reported to the following nodes in the pipeline. I'm having trouble with the second case; specifically lexical events such as comments are not being passed to the next node. Each node defines a setOutputHandlers() (below) that sets the handlers for events generated by that node. For the xslt wrapper, I simply create a SAXResult using both the ContentHandler and the LexicalHandler and then proceed to create the TransformerHandler member that will receive SAX events from the previous node. Is there something I am doing wrong here that would prevent my xsl stylesheet from passing the lexical events to the next node? I have already verified that the transformation correctly passes through comments in XMLSpy and that my framework is correctly invoking transformerHandler.comment() when a comment event fires on a previous node. Thanks for any help, thoughts, or suggestions. Collin -------------------------- public void setOutputHandlers(ContentHandler content, LexicalHandler lexical) throws SAXException { super.setOutputHandlers(content, lexical); this.result = new SAXResult(); this.result.setHandler(content); this.result.setLexicalHandler(lexical); try { final String xslt = fetchXSLTAsString(); final SAXSource xsltSource = new SAXSource(new InputSource(new BufferedReader(new StringReader(xslt)))); final SAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory.newInstance(); this.transformerHandler = factory.newTransformerHandler(xsltSource); this.transformerHandler.setResult(this.result); } catch (Exception e) { throw new SAXException(e); } } ============================================================================== You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer" group. To post to this group, send email to [EMAIL PROTECTED] or visit http://groups-beta.google.com/group/comp.lang.java.programmer To unsubscribe from this group, send email to [EMAIL PROTECTED] To change the way you get mail from this group, visit: http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe To report abuse, send email explaining the problem to [EMAIL PROTECTED] ============================================================================== Google Groups: http://groups-beta.google.com
