• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Communication with Servlets

 
Sameera Abeysinghe
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • 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 ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your servlet class extends what?
 
Sameera Abeysinghe
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have edited the original post
Thank you
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that it is possible to connect to a URL that contains GET parameters in this fashion?
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Amarender Reddy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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: 42967
73
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic