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.
hareesh Puthala
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32421
posted
0
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.
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
Marshal
Joined: Mar 22, 2005
Posts: 32421
posted
0
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
Joined: Jan 11, 2010
Posts: 16
posted
0
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?
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
Joined: Jan 11, 2010
Posts: 16
posted
0
Now it is not even calling the appletcontext.showDocument().
Why this is happening?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32421
posted
0
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.
This message was edited 1 time. Last update was at by Ulf Dittmer