• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

embedding a JTable in a JSP

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,
Can any one give me an idea how I could place a JTable whose details come from a DB in a JSP.
Thanks a lot
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy and welcome to the Ranch!
You cannot use Swing elements in a JSP page. You might want to investigate using an applet if that's appropriate for your app.
hth,
bear
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know JTable is a swing class used in a GUI application or applet. A JSP on the other hand runs on a server and typically generates some HTML to hand back to a browser.
I can't work out how or why you would want to mix two such very different things. Can you clarify a bit more about what you want to achieve with this?
 
vikram duri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
Howdy and welcome to the Ranch!
You cannot use Swing elements in a JSP page. You might want to investigate using an applet if that's appropriate for your app.
hth,
bear


Hi
Thanks for your reply.
My present stage is that I have an ordinary table showing me some records in a JSP page. But the requirement is that the records should be editable(mass updates or mass deletes). the user wants a functionality of deleting records as we do in an excel sheet(holding a shift key and press delete for multiple delets). For that the only option I have is to use a JTable. I cannot use an applet as the records are from multple tables in a DB. I am also scared about the performance as swing is heavy weight.
Hope this explains as to why I need such a peculiar requirement.
Thanks a lot.
Regards,
Vikram
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cannot use an applet as the records are from multple tables in a DB.
This has got nothing to do with whether you can use an applet or not, that's up to how you code your JDBC access and how you transfer the data to the applet. I've seen plenty of applets showing and accessing data from multiple tables, multiple databases and even mixing things like database access and web services.
The bottom line here is that if you want anything smarter than a basic HTML form with a bit of JavaScript validation you really have to use an applet. Especially if you want to use something like a JTable.
I can't stress this strongly enough: All the JSP does is build an HTML page and send it to the browser. The JSP code has finished running long before you see the page in the browser - if you "view source" on the results of a JSP in a browser you don't see Java, just the HTML it has generated. You cannot run GUI code like Swing, AWT, or SWT on a server and expect to see anything in a browser.
For that the only option I have is to use a JTable.
...
I am also scared about the performance as swing is heavy weight.

Not quite. It's still possible to use a slightly lighter approach. You can code an excel-like applet using AWT and Java 1.1, which is supported on a lot more browsers. Your best bet, though, is to look through the software component suppliers and shareware/open source repositories for spreadsheet components, and use one somebody has already written in your own applet.
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no problem here using an applet. Just be aware that your clients must have a JRE installed. Also, last I checked, using Swing in applets caused some funky browser issues. Last I did it was a couple of years ago, but if I remember correctly, the client had to have a special plugin and the html code surrounding the applet tag needed to be modified.
 
Create symphonies in seed and soil. For this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic