Solved

Applets + JavaBeans

Posted on 2003-11-10
4
285 Views
Last Modified: 2013-11-24
Hi,

The problem is that I'm developing some graphical reports with (java AWT-Swing) so I'm using applets.

The question: is there any way to use JavaBeans with applets. The thing is that I need to access my database throw an Applet. The code is down below (no errors...no results... and there is nothing in logs either).

The thier arrangment is :    Web browser<--> Apache <--> Tomcat <--> PostgreSQL

Any ideas... ? Any solutions... ? I'm open to sugestions even if I have to throw to the waste basket my applets and starting to use some servlets or something like that.

*************************************************
import java.awt.*;
import java.awt.*;
import java.applet.Applet;
import Biblioteca.ConexionBean;

public class Prueba extends Applet {
  public void init() {
    ConexionBean base;
    base = new ConexionBean();
    String p_cveproyecto = getParameter("p_cveproyecto");
    String sql = "";

    add(new Label("Clave del proyecto"));
    add(new Label(base.Prueba(p_cveproyecto), Label.RIGHT));
  }
}

Thanks in advance!
0
Comment
Question by:lowg
4 Comments
 
LVL 2

Accepted Solution

by:
incongruent earned 125 total points
Comment Utility
What you need to do is create a ObjectOutputStream/ObjectInputStream from your servlet to your applet.  (Client - Server architecture).  

You servlet must access the database and construct a 'DataObject'.  I am currently working on an applet that gets dataobjects in an arraylist via the OOS/OIS then performs a method to construct the tree from the arraylist.

If you're looking for a direct database connection from your applet to the database,  you would require a signed servlet.  To sign a servlet you need to get a certificate from Verisign or something along those lines.  

I suggest you revise your reporting function to use an arraylist of dataobjects instead of a direct data connection.   Have the servlet perform the data connections and SQL queries and fill arraylist(s) with dataobjects constructed from SQL queries.  Then send those arraylists of ObjectOutputStream via the servlet.



-Allan
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now