Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Applet calling Servlet

 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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: 23209
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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......
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic