• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

How applet can access database using browser ??????????

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey ppl....
Is there nobody who can tell me the answer for this I am really and veri badly stuck in b/w ....Meriii nayiiyaa paar lagwaa do...bkds...this is my 100th query regarding the same...If in this world ani body knows this either mail me a sample file of policy or tell me the solution step by step..
Chaloo fir miltey hai...
Bhaiyoon ko Pardaaam,
Aur saarey bhaiii ki baheenon ko Mera pyaar bhara Hug.
Deepak Yadav
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are lots of techniques through which you can make applet accessing (server residing)database.
Applet can access database through http protocol.
1.Use thin drivers if server has specific ports opened for outside world. (these drivers are available on net. )
2.Use servlet to do your database part, communicate with servlet to retrive data.
3.Write any server program & implement HTTPTunneling & decide your own tags to communicate to server program!
4.There is one more method, applet can access database using RMI communication too. I will not recommend this anyway.

PuneGuy !
 
Deepak Yadav
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all Thanks very much for your reply.
Could you please send a sample code in which servlet is communicating with Database and sends the data back to Applet....
We are doing the same thing mentioned above, which works fine in Appletviewer but is not working in Browser....
Could you please send us sample code which defines the technique to run it in browser.....
 
java puneri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Deepak
I am sorry I can't send you any code for some reson as you understand!
I can tell you brief here !
following function should be there in SERVLET
I will call the following function from the doGet or doPost method of the servelt.
-------------------------------------------------------
public void senddata(HttpServletResponse response,String data){
ObjectOutputStream outputToApplet = null;
try{
outputToApplet = new ObjectOutputStream(response.getOutputStream());
outputToApplet.writeObject(data);
outputToApplet.flush();
outputToApplet.close();
}catch(Exception e){
System.out.println("MyServlet: senddata() "+e.toString());
}
}
----------------------------------------------------------------
Let me explain!
String data in parameter of the above method is the data to be sent to applet.
We are sending the object so it could be anything like StringBuffer,ResultSet etc.
Thats servlet part over!
_________________________________________________________________
Applet part!:-
public Vector getdatafromServlet(){
ObjectInputStream inputFromServlet = null;
try{
URL servletURL = new URL(servletLocation);
URLConnection servletConnection = servletURL.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches(false);
servletConnection.setDefaultUseCaches(false);
servletConnection.setRequestProperty("Content-Type","application/octet-stream");
inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
String resultdata = (String)inputFromServlet.readObject();
inputFromServlet.close();
}catch(ClassNotFoundException e){
}
catch(Exception e){
}
finally{
return resultdata;
}
}
----------------------------------------------------------------
In above function servletlocation is the url where servelt is located.
Just check out for returntype of inputFromServlet.readObject();
(I used Vector)

________________________________________________________________

I implemented the above communication I was through this So it has to work. Play around the code.
I found the above code Internet only so if you search a little bit more you will get the zip of the source code. Javawebserver 2.0 has this example!, Even you will find example in BEA weblogic server I Guess. I am sure about JWS2.0 Example.
BEST OF LUCK !
Further need assistance, I will help you ! But can't send any code to you.
 
java puneri
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Deep
I found the link, Hope that helps you
B.O.LUCK

Link
http://www.j-nine.com/pubs/applet2servlet/index.htm

Downloadable ZIP
http://www.j-nine.com/pubs/applet2servlet/applet2servlet.zip

PuneGuy !
 
Deepak Yadav
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks A lot Dear
Deepak
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic