• 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

applet or jsp for comm with servlet ?

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Have a few doubts regarding applet-servlet communication.Will some one pl help?

(1) Is there any advantage in using applet as front-end for communication with servlet over say JSP? If so what are they? and when should you use an applet/JSP?

(2) I am using an applet as front-end and has got two buttons ,"Register" and "Get Details". It sends a serialised object to the servlet.
(i) Now, in the servlet,how can i find out which button has been
clicked in the applet?(like getParameter("Register") method, using
request object, is there any way to determine which one has been
clicked in applet?)
(ii) How can you pass a parameter to the constructor when the object is
deserialised in the servlet?(because you will be using
ObjectInputStream and then casting it, to get back the object.)

(3) What is the difference between ServletOutputStream and PrintWriter?

(4) Can Hashtable and Vectors be serialised properly?

(5) Is is enough to have just one connection to database to cater to all the requests that comes to a servlet?ie. do you need one connection each for every request that ask for data from datatbase or only a single connection that the servlet may create in init()?

(6) Whats the difference between service(HttpServletRequest...) and doPost(HttpServletRequest.....)/doGet(HttpServletRequest.....)?When do you use them?

Thanks very much
gthri
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Will try and answer a few ....Folks correct me in case i am wrong !
-------------------------------------------------------------
Hello,

Have a few doubts regarding applet-servlet communication.Will some one pl help?

(1) Is there any advantage in using applet as front-end for communication with servlet over say JSP? If so what are they? and when should you use an applet/JSP?

(2) I am using an applet as front-end and has got two buttons ,"Register" and "Get Details". It sends a serialised object to the servlet.
(i) Now, in the servlet,how can i find out which button has been
clicked in the applet?(like getParameter("Register") method, using
request object, is there any way to determine which one has been
clicked in applet?)
(ii) How can you pass a parameter to the constructor when the object is
deserialised in the servlet?(because you will be using
ObjectInputStream and then casting it, to get back the object.)

(3) What is the difference between ServletOutputStream and PrintWriter?

(4) Can Hashtable and Vectors be serialised properly?

(5) Is is enough to have just one connection to database to cater to all the requests that comes to a servlet?ie. do you need one connection each for every request that ask for data from datatbase or only a single connection that the servlet may create in init()?

(6) Whats the difference between service(HttpServletRequest...) and doPost(HttpServletRequest.....)/doGet(HttpServletRequest.....)?When do you use them?

Thanks very much
gthri
------------------------------------------------------

1) When the gui is very rich - in the sense if there are multiple tabs and child tables in each of the tabs and you have very complex validations in the client side like if field 1 has a value make the child table 1 mandatory and tab 2 mandatory else tab 3 mandatory etc - then applet can be used.But at the same time think abt the speed and security aspects as well.

2) When you are using two buttons in the applet why not just add a value that would take the mode (set this value as 1 in case "Register" is pressed else 2 in case "Get Details" is pressed - which can be an int and this can be passed along with ur object which is serialised) and retrieve this int from the object in the servlet and do the processing ..

5) Why cant you use a connection pooling(DataSource) and open and close connection per request ? Depends on the load as well...

6) HTTPServlet overrides the service method and has implemented doPost,doget etc ...So in case your servlet extends HTTPServlet and you override service then obviously you cannot have support to doPost,doGet etc ...

May be it helps ...
[ February 10, 2005: Message edited by: Maybach Smith ]
 
chelakkad ben
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the answers,Maybach.

Regarding #5,supposing i get about 200 requests,do i need to have 200 connections kept open and ready?
Answer to #6 is not clear to me.Could you be a little more specific?
I am new to servlets!

thanks once again
gthri
 
Maybach Smith
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi cb gthri,

Please find the following lines taken from Core-Servlets and JSP by Marty Hall.This would help you understand why we should not override the service method in HTTPServlet :

1.You can add support for other services like doPost,doGet,doPut,
doTrace, etc., perhaps in a subclass. Overriding service
directly precludes this possibility.
2. You can add support for modification dates by adding a get-
LastModified method. If you use doGet, the standard service
method uses the getLastModified method to set
Last-Modified headers and to respond properly to conditional
GET requests (those containing an If-Modified-Since
header). See Section 2.8 (An Example Using Servlet Initialization
and Page Modification Dates) for an example.
3. You get automatic support for HEAD requests. The system just
returns whatever headers and status codes doGet sets, but omits
the page body. HEAD is a useful request method for custom
HTTP clients. For example, link validators that check a page for
dead hypertext links often use HEAD instead of GET in order to
reduce server load.
4. You get automatic support for OPTIONS requests. If a doGet
method exists, the standard service method answers OPTIONS
requests by returning an Allow header indicating that GET,
HEAD, OPTIONS, and TRACE are supported.
5. You get automatic support for TRACE requests. TRACE is a
request method used for client debugging: it just returns the
HTTP request headers back to the client.
 
Wink, wink, nudge, nudge, say no more, it's a 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