javabeans

Strange behaviour of ArrayList

Hello everybody. I am writing a website using JSP, JSTL, Servlets and JavaBeans. At one point of my code, I am trying to use an ArrayList of objects, and a strange thing is happening: when I add the first object it is fine, and when I add a second object it adds it in the second place, but the object at index(0) gets the same values as...

JavaBeans Classes in Separate JAR Files

Is it possible to build classes for a JavaBean in separate JAR files? Specifically- a JavaBean has the Bean and BeanInfo classes in one JAR file and the Custom Property Editor class inn a different JAR, the JAR file with the Bean and BeanInfo classes has the JAR file with the Custom Property Editor class on the classpath, but during dra...

redirect from jsf ?

Hello everybody, I am working on application with jsp, jstl and jsf for my college project, thats being said, I am as well very new to jsf. Everything is going great so far. However, I seems to have a problem figuring out how to do redirect from managed bean to page with dinamyc parameters. For example article.jsp?article_id=2 Can som...

Standard action

Hi, I really don't understand why the following code in JSP is running fine, but as described in Head first book, it will show compile time error. <html><body> <jsp:useBean id="person" type="foo.Person" scope="request"> <jsp:setProperty name="person" property="name" value="Fred"/> </jsp:useBean> <jsp:getProperty name="person" prope...

JavaBeans and DSLs

It's 2009 and we still all hold on the JavaBeans despite all their flaws, mostly because of the tooling support which we wrote in our own blood. But now we have method chaining and internal DSLs and some pressure to replace or extend JavaBeans with DSL classes. Has anyone an implementation that implements PropertyDescriptor for a DSL (w...

.dll already loaded in another classloader?

I have a webapp running under Tomcat 3.2.1 that needs to make JNI calls in order to access data and methods in legacy C++ code. A servlet is loaded on startup of the webapp that, as part if its init method, causes a data set specific to that webapp instance to be loaded into the C++ data structures. This Java code for this s...

How to save data upon http session invalidation through jsp / servlets?

To track user activity history on a web application, I am attempting to save some session data to a database when the session is invalidated. My initial approach was to store the data on a javabean with a session scope and have it dump its data to the database through the finalize method. I figured this wouldn't be a perfect solution du...

How can a JavaBean get the directory of the user interface project it is dragged and dropped into?

Using NetBeans and custom JavaBeans. The users will create new user interface projects in the directory they choose, and when a JavaBean is dragged and dropped onto the user interface in the project, the JavaBeans needs to know the directory of the project in which it is used, because it will sopy resource files there. The file copy sh...

Java bean with JNI ?

I have added native method in java bean code. Then i have copied .dll file in System32 folder. while using javabean in JSP. it gives an Error: HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperE...

problem with dbConnection, reading in context-params from web.xml

i have some jsp code that reads in Servlet Context parameters from a web.xml file. these parameters hold database connection information so each time the SID or user/password or servername changesm, the programmer doesnt have to go re-code; the user can just change the web.xml file. <context-param> <description>database user name</des...

An exception raised when trying to access a JavaBean

Hi everyone, I'm a newbie on Java EE and got a problem that I don't understand why it's happening. Here is my problem : I can't access a JavaBean using <jsp:getProperty> which is created in a scriptlet in the same page.It's throwing the below exception : Attempted a bean operation on a null object. Here is my bean and jsp page : pac...

Java Interface Usage Guidelines -- Are getters and setters in an interface bad?

What do people think of the best guidelines to use in an interface? What should and shouldn't go into an interface? I've heard people say that, as a general rule, an interface must only define behavior and not state. Does this mean that an interface shouldn't contain getters and setters? My opinion: Maybe not so for setters, but some...

Newbie question about Java

Okay, I know that Java is a language but somebody has asked me if they can write a web application to interface in with a web app I've written in ASP.NET. I'm implementing a web service to serve up an XML so it's pretty language agnostic. However, I'm not 100% sure whether going down the Java route makes a lot of sense. I was kind of ex...

BeanUtils with an addXX method

Hi, I'm using the Apache BeanUtils setProperty method to import data from an Excel file in a generic manner. I provide the parser a list of "colum name" and "property name" pairs and then the parser sets the properties with setProperty( ..., "property name", ...) for the Excel fields that match with "column name". It's working nice but ...

BeanUtils with Maps

How can I use the BeanUtils setProperty method with Maps. For example, this method: public void setAddress(String type, Address address); Can be setted using: BeanUtils.setProperty(beanObject, "address(home)", addressObject ); But if the object I want to set is a Map, is it possible? how? ...

Can I use ObjectChangeListener to listen for changes on any object?

I've got an Integer called x; if it changes then i would like to update my table in a GUI. To listen to "x" I have tried ChangeEvent y = new javax.swing.event.ChangeEvent(x); and I implement javax.naming.event.ObjectChangeListener: class HDIManagementView extends FrameView implements ObjectChangeListener, ActionListener, T...

Saving a PNG file on a server in a Java bean, using JSTL

I am writing an update page in JSTL where the user inputs some numbers. I then call a java bean - passing the numbers as parameters - which, using JFreeChart, creates a PNG image. All of this works fine when I save the file directly on my hard drive using ImageIO.write(myBufferedImage, "png", new File("C:/testChart.png")); I can al...

Has the JavaBean spec been updated to reflect the existence of annotations

I thought this should be obvious but I can't find it. Now that fields can have annotations, I thought this should be reflected in the JavaBean spec, but I can't find it. What I mean: JavaBean is a specification that allows you to treat objects in an uniform way by discovering their properties, and then reading and writing them. As PO...

Difference between Javabean and EJB

Just a simple question from a relative Java newbie: what is the difference between a JavaBean and an EJB? ...

why use jsp:useBean here but not just create a new object ??

In a JSP page, there is such code: <jsp:useBean id="checklog" class="com.google.admin.guard.CheckLogBean" scope="session" /> and then <% checklog.checkit(); %> Why we don't just create the object with new com.google.admin.guard.CheckLogBean? What's the benefit of doing this? And in the source code, there is no such class, but wh...