• 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 calling Servlet

 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Randall Twede
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Trailboss
Posts: 23778
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
 
Randall Twede
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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......
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic