• Post Reply Bookmark Topic Watch Topic
  • New Topic

Communicating across contexts  RSS feed

 
Craig Dixon
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a servlet called QuizGraderServlet. I have written it as generally as possible to allow it to grade many different online quizzes from my site. Each quiz is, in turn, it's own web application (has it's own ServletContext apart from QuizGraderServlet.) The flow of control usually proceeds as follows:

1. User starts at beginning of individual quiz (i.e. in the individual quiz's context).

2. User proceeds through quiz; session variables are created.

3. User takes online quiz; control passed to QuizGraderServlet context.

4. QuizGraderServlet returns control to individual quiz servlet context; session variables needed again.

I've addressed this by having QuizGraderServlet obtain the JSESSIONID from the incoming HTTPServletRequest and append it to the URL when it passes control back to the individual quiz context. Thanks to URL rewriting, the individual quiz context picks up on the JSESSIONID in the URL and seamlessly picks up the session again.

My problem now is that I need to create some information inside the QuizGraderServlet context and pass it back out to the individual quiz context. Session variables are no longer an option (are they?) because the individual quiz context has no access to the QuizGraderServlet context, and hence, no access to any of the sessions in the QuizGraderServlet context.

I would really like to avoid tacking the information on the end of the URL, since that would make it easy to modify, and that could produce an undesirable result. Is there any way to send information from the QuizGraderServlet back to the individual quiz context without having to send it "in the clear"? I'm looking for something like an HTML form's POST method, but don't know any way to acheive that with a servlet.
 
Craig Dixon
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, if I understand this correctly, this package would allow a servlet to send using HTTP POST. Is it just a jar to put in [webapp]/WEB-INF/lib? Are the API docs included with the download? Do you recommend the latest stable build, or the release candidate?

Nothing in the standard servlet API supports this?

Sorry, that's a lot of questions.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Craig Dixon:
So, if I understand this correctly, this package would allow a servlet to send using HTTP POST. Is it just a jar to put in [webapp]/WEB-INF/lib? Are the API docs included with the download? Do you recommend the latest stable build, or the release candidate?

Nothing in the standard servlet API supports this?

Sorry, that's a lot of questions.


Yes,
Yes,
Yes,
Latest stable (unless there is something new you're looking for),
There is java.net.UrlConnection
. It may take a little more work but there are plenty of examples on the web.

No problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!