Win a copy of AWS Security this week in the Cloud/Virtualization 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Applet Servlet Communication

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please help me out in this issue.


Our requirement is that Applet (PrintApplet in our case)just needs to send a value(jsp page name)
to a servlet(AppletListenerServlet in our case) and that servlet needs to redirect it to the page which is sent by the Applet.

My applet request is able to reach the servlet and i am able to get the jsp page value in the servlet,but the servlet is not able to forward the request to that jsp instead of that the same applet page is displayed.

Servlet is not able to forward the request.

Could you please please please help me out in this ....

Many many thanks in advance.
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the applet calls the servlet using java.net.URLConnection or something similar? If so, then the servlet can't cause the applet page to redirect to another page - the applet needs to do that by calling AppletContext.showDocument.
 
hareesh Puthala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:So the applet calls the servlet using java.net.URLConnection or something similar? If so, then the servlet can't cause the applet page to redirect to another page - the applet needs to do that by calling AppletContext.showDocument.




Iam getting this Exception while iam trying to call the method 'this.getAppletContext().showDocument(url)';


Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at sun.plugin2.main.client.MessagePassingExecutionContext.showDocument(Unknown Source)
at sun.plugin2.main.client.MessagePassingExecutionContext.showDocument(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletContextImpl.showDocument(Unknown Source)
at PrintApplet.actionPerformed(PrintApplet.java:105)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

But the appletcontext object is not null which i found on the java console.

Thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The NPE occurs in the showDocument method, so the AppletContext is obviously not null.

What's the value of the URL you're passing in? In which browser does this happen?
 
hareesh Puthala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:The NPE occurs in the showDocument method, so the AppletContext is obviously not null.

What's the value of the URL you're passing in? In which browser does this happen?




Value of the URL is: http://10.16.1.43:8090/collectionpak/pages/consumerService.jsp

And the browser is IE 6.0
 
hareesh Puthala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hareesh Puthala wrote:

Ulf Dittmer wrote:The NPE occurs in the showDocument method, so the AppletContext is obviously not null.

What's the value of the URL you're passing in? In which browser does this happen?




Value of the URL is: http://10.16.1.43:8090/collectionpak/pages/consumerService.jsp

And the browser is IE 6.0




Here is my code:

I am performing spme business logic in the create method(It creates a text file in the local file system and drives the default printer and prin ts the text file.)


Please look into this ...
Thanks a lot for helping me.
 
hareesh Puthala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now it is not even calling the appletcontext.showDocument().

Why this is happening?
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is never a good idea:

You need to do proper error handling. At least put something like "e.printStackTrace()" so that you know what happened.

Also, does "urlstr" have any meaning? It is not used in the code.
 
hareesh Puthala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Ulf Dittmer..

It has done the trick.

Once again thank you very much......
 
I'm all tasted up for a BLT! This tiny ad wants a monte cristo!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic