• 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

Communication with Servlets

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
This is my Clint

This is my servlet


This is the error I am getting

run-single:
done 1
java.io.StreamCorruptedException: invalid stream header


My problem is how my application can get the data taken from MYSQL database by the servlet
I want to view this data in my application
This application(Not the servlet. The one on the Clint side)is not an applet(web based). It is a class that extends JFrame(The one with the getdeleteText() method).

Thanks you
[ October 28, 2005: Message edited by: Sameera Abeysinghe ]
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your servlet class extends what?
 
Sameera Abeysinghe
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have edited the original post
Thank you
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure that it is possible to connect to a URL that contains GET parameters in this fashion?
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe calling connect.setDoOutput(true); makes request post and servlet expects post data. Remove it or do false.
 
Sameera Abeysinghe
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for the fast reply�s

Are you sure that it is possible to connect to a URL that contains GET parameters in this fashion?


I believe calling connect.setDoOutput(true); makes request post and servlet expects post data. Remove it or do false.


I am very new to servlet programming so a working code will be a big help

This is what I want to do

I send the groupid(variable group) to the servlet through the url. It works fine.
The servlet takes that groupid and get some data from the database. That also works fine.
My problem is after getting the data what I have is a result set. I want the data in this result set to be shown in my application.
How can I do it
(I think the servlet has to send it so �.)
Thanks
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

If your application has a JSP front-end with more number of fields and othe rdata vallidations to be done then you should be using taglibs ( the very famous ResultSetIterationTag ) ..........or if your application has only few fields to be populated then directly put them in a session and access them at front-end.

hope u understood

regards,
amar

****************************************************************************


BE GOOD AND DO GOOD. THAT IS THE WHOL EOF RELIGION.
-- Swami Vivekananda
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see what JSP has to do with any of this.

One basic problem you have is that you call both response.getOutputStream and response.getWriter. That won't work, you can only use one of them at a time. (I'm actually surprised you're not getting exceptions when you do that, but that's a different topic.)
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sameera Abeysinghe:
My problem is after getting the data what I have is a result set. I want the data in this result set to be shown in my application.
How can I do it
(I think the servlet has to send it so �.)



Yes you need to respond back after processing. Technically, you need to take a request dispatcher from your request object and then do forward. It would be forwarded to the view/JSP. Otherwise you can render the response in your servlet as well.

Tip: While forwarding request to some JSP page in order to show the result. Bind your collection of TO to request object. Where collection of TOs would be filled by your resultSet.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you are a newbie, I must tell you about TO.
 
Sameera Abeysinghe
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ones again Thank You for the reply�s
But I am not sure you all understood my problem.

amarender reddy -- your application has a JSP front-end with more ....

My application is not web based(so no jsp or applets)
Sameera Abeysinghe -- side)is not an applet(web based). It is a class ....

Ulf Dittmer -- actually surprised you're not getting exceptions ...
I was testing to find a way to do this so don�t know what exactly I did

Adeel Ansari -- Tip: While forwarding request to some JSP page in order to show the result...........
My application is not web based(so no jsp or applets)
Sameera Abeysinghe -- side)is not an applet(web based). It is a class ....

The link TO is useful. But not sure it can do what I want
So more reply�s is always well come.

Thanks a Lot for all your fast reply�s
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you trying to read the response as an ObjectInputStream?
It is very clearly going to be a text stream since you did a response.getWriter(0)
Of course it is corrupted.
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic