aspose file tools*
The moose likes Servlets and the fly likes Applet calling Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Applet calling Servlet" Watch "Applet calling Servlet" New topic
Author

Applet calling Servlet

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

When the "quit" button is clicked in the applet nothing happens. "next" button still works.
<HR></BLOCKQUOTE>
no exceptions in java console
I tried adding this line in try block of quit() but same problem.
con.connect();
It looks like maybe
response.sendRedirect("http://javaguy.yi.org/examples/MoreQuiz.html");
is being sent to to applet not the browser. How do I do this?
In case it isnt clear. When quit is pressed I want to update the session then replace the page containing the applet with a new page.

[This message has been edited by Randall Twede (edited February 10, 2001).]


SCJP
Visit my download page
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

OK I solved part of the problem. The new page is being displayed but the servlet is apparently not getting called. The value of "balance" in the session remains unchanged.
<HR></BLOCKQUOTE>
I would actually rather use doPost() for this and use doGet() of the same servlet to initialize the "total" variable of the applet.
[This message has been edited by Randall Twede (edited February 10, 2001).]
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

I would actually rather use doPost() for this and use doGet() of the same servlet to initialize the "total" variable of the applet.
here is what I have in the applet so far(relevant code only)
<HR></BLOCKQUOTE>

here is what I have for the servlet so far.
<HR></BLOCKQUOTE>

[This message has been edited by Randall Twede (edited February 10, 2001).]
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
I think the problem is using a session in your servlet. Well not actually the servlet but, the URL class from the applet. A browser normally stores the session value and returns it in the header of the next request. To use this from Java you have to specifically do this your self.
On return from the first connect you can use the methods
getHeaderFieldKey(int n) and getHeaderField(int n) and store these, (investigate them, you only need the one for the session)
On subsequent request you set the fields using
setRequestProperty(String key, String value)

------------------
Hope This Helps
Carl Trusiak


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20647
    ∞

A coupla tips:
First, check out www.javaranch.com/common.html and look for HTTP and ObjectServlet
Next, swing by http://www.javaranch.com/bunkhouse/bunkhouse_J2EE.jsp and look at the sample chapter that comes with "Java Developers guide to Servlets and JSP"


permaculture Wood Burning Stoves 2.0 - 4-DVD set
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

YES!
It works perfecly in IE. However the balance doesnt get changed in Netscape.I tried both of these Content-Types:

Does any one see any problems with this code to explain why it doesnt Post using Netscape?
Applet code:

servlet code:
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi,
i am getting the same problem as u were facing.
Please give me solution for that if u have got it.
(Not able to post data on servlet thr netscape.)
Thank's,
Hiren......
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet calling Servlet