Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

Robert Miller

Ranch Hand
+ Follow
since Jun 18, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Robert Miller

It doesn't look like there is a problem finding select.do, since according to the error message you posted it knew to look for BeerSelect. I'm concerned that the message mentions BeerSelect.java, since the web container shouldn't need or even know about the source file.

Have you verified that the class file is correctly installed? It has to be in .../beer-v1/WEB-INF/classes/com/example/web/BeerSelect.class.
11 years ago
I've managed to get approximately 8 years experience with core Java without working in enterprise development. I'd like to do some web development, but most of the companies I've talked with are looking for someone with professional experience, and who can blame them?

I'm currently working on a side project that will eventually make use of most of the areas of web development. I've only been working on it for a month (and not fulltime) but I've already been able to talk about it in some interviews. What else can I do to help myself? I've heard the suggestion to work on some open-source project in J2EE to get some experience. How would I find one?

Also, I might be taking a position soon that would be C# and .NET. How would experience with those technologies look to a J2EE employer down the road?
[ July 17, 2008: Message edited by: Robert Miller ]
11 years ago
I'm looking into using Hibernate for a database project. We intend to have multiple clients on multiple systems making updates to the database, and we also want a task to be started on a particular system whenever a particular table is updated.

I've looked through Hibernate documentation and it looks like an Interceptor might solve our problem, but it says an Interceptor is started when the session updates the database. Does that mean it will only intercept updates by that particular process? I need a way to be informed of any update.

If an interceptor can't be triggered by a general update, is there something else that will work?

Thanks,
Robert
All of the examples for EJB's I've seen involve some sort of e-commerce. I have a situation that is not e-commerce but looks like it might be a good candidate for using EJB's. I hope anyone with J2EE and EJB experience can let me know whether I am on the right track.

We are designing a system that will serve as sort of a master for other systems in the network. It will have a database, but we want to mask the details of the database from the rest of the system as much as possible. The other systems will need controlled access to the database, and all information passing over the network needs to be encrypted. We would like to have information added to the database initiate an action on one of the other systems, but I don't know of way to use EJB to do that.

What do you think? Is EJB overkill, or the wrong solution altogether? Or am I on the right track? I've played around with EJB but never used them on a large scale system.

Thanks.
I'm working with a Java application that uses Socket objects for communication and I'm seeing something strange, that I hope someone can help me with.

The system consists of a process that listens for connections from other processes. The client processes create a Socket object and bind it to a specific port number so that the server process can identify the client on connection. The code looks like this:



This code works fine if hostname is not set to "localhost". If it is set to any hostname on the system, or any IP address (including 127.0.0.1), it works. If it is set to "localhost" the connect() call gets a ConnectionRefused exception.

If the bind() call is commented out, then the code always works even if hostname is set to "localhost", but then the server process can't identify the client on connection.

Does anyone know why this code is failing and what I can do to fix it?

Thanks,

Robert

Originally posted by Jeanne Boyarsky:
Robert,
<loadFile> loads the entire contents of a file into a property. If your file just contains the version number, this sounds like what you are looking for.



That's exactly what I needed! Thank you very much!
13 years ago
I have a file on the build system that contains a version number. I would like to set an Ant property to the contents of the file. The file is not in any kind of "property=value" format.

I've looked at the list of Ant tasks and haven't seen anything that looks like "read input from a file and set the contents to this variable". Can anyone tell me how to do this?

Thanks,

Robert
13 years ago
I have some modal dialogs (created using JOptionPane.showXXXDialog methods) that I need to replace with non-modal dialogs. The dialog is already running in a separate thread (it is kicked off by an asynchronous event) but I need the user to have access to other parts of the GUI. On the other hand, since the dialog is to be presented in response to an asynchronous event, I need to know precisely when the dialog goes away, because the response to the dialog is necessary to handle the event.

For some reason I can't find very much information on non-modal dialogs. Can anyone help?
14 years ago
I'm working on a build process for a Java project which is part of a larger project containing Java and C++ code. I want the Java code to have access to a global version number. If I were doing this in C++ I'd compile it as "g++ -DVERSION=...", but that capability doesn't seem to exist in Java.

Instead, I'm implementing an Ant task as below. Is this the "correct" way of doing things? I haven't seen the <filter> task used this way in any of the documentation I've consulted so I'm a little concerned. I've also noticed that this won't remake the file if the version number changes. How do I get around this? Should I add a task that removes the generated file, that gets called from the scripts that build the full release?

My task is:




Thanks!
14 years ago
I'm studying servlets and JSP's and I was thinking about how they could be applied to a system I'm working with. The current system consists of one process which manages the state of the system, which serves user interface programs running in different processes. The processes communicate using a socket connection, with messages being sent when the state changes.

I've been wondering how I could put a web interface on this system. The problem is I would need an object running in a different thread to process the messages. I could create that object when the ServletContext is initialized and query it from within servlets. Is this a good idea? Is it even allowed? If not, can anyone suggest how I might do this?

Thanks!
14 years ago
I am working with a dialogue box containing text fields. I need to add logic so that if a certain character is entered, the focus progresses to the next field. I'm using KeyboardFocusManager.focusNextComponent() and that works fine.

I also need to add logic so that if another character is entered, the focus returns to the first field. I can't find a method in KeyboardFocusManager to do that, and I also can't find any documentation that addresses this problem.

Can this be done with KeyboardFocusManager, or do I have to try another approach?

Robert
14 years ago
I have an application using a JList and I want to implement the additional restriction that as long as the list is non-empty there will always be one element selected. I am using the SINGLE_SELECTION model but that allows the user to deselect the current item and leave no elements selected. I suspect I can accomplish what I want using a ListSelectionListener but I haven't found enough documentation on that object for me to determine whether it would be helpful.

Is there anyone out there who can help me out with this?

Thanks!

Robert
14 years ago
I have a problem which seems so elementary that I'm embarrassed to bring it up, but I can't find the solution through the javadocs or my other resources.

I have a JTextPane which I am using to display data, output only. I am placing it in a JScrollPane. What I want to do is have it scroll to the bottom when I add text to it. Manually setting the vertical scroll bar to its maximum value doesn't seem to work.

Can anyone help me with this?

Thanks!
14 years ago
I'm having some problems understanding how components are sized and I hope someone can help clear them up for me.

I have a panel which is using a BorderLayout. I have a panel in WEST and a panel in CENTER. The panel in CENTER contains a JScrollPane which contains a JTextPane. It seems like no matter what I do the scroll pane and the text pane all appear very small, about one line high and one character across. I want it to fill the entire region.

I am almost embarrassed to ask the question because I suspect it is very easy to solve, but I'm also new at Swing. Can anyone tell me what I need to do to get the component to fill up the region?

Thanks,

Robert
14 years ago
I'm working on a project requiring me to maintain a window with multiple lines of text, each of which is to be displayed using a particular color. My first instinct was to use a JTextArea wrapped in a JScrollPane, but that does not give me the color control I need.

Similar code in this project solves the problem by directly extending JComponent and overriding paintComponent(), but I figure there has to be a more straightforward way of handling this problem. Can anyone tell me how to do this?

Thanks,

Robert
14 years ago