This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java servlets extending jpanel  RSS feed

 
Shobana Sukumar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it possible to extend jpanel in a servlet.if so kindly illustrate with an example.....
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. JPanel is a Swing concept, not an HTML concept.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although I can just about imagine an application with a Swing UI that also serves HTTP requests, it does not really make sense to do both these functions in a single class.

Apart from anything else, the great majority of Servlets extend from GenericServlet or HttpServlet, and thus cannot also extend from JPanel. While you could get round this by implementing the basic javax.servlet.Servlet interface in your JPanel class, it would be very weird indeed to have a JPanel created and managed by a web server.

Can you explain a bit more about what you are trying to achieve by doing this?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!