File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet Servlet Communication

 
hareesh Puthala
Greenhorn
Posts: 21
  • 0
  • 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.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • 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
  • 0
  • 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
Pie
Posts: 42966
73
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
Pie
Posts: 42966
73
  • 0
  • 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
  • 0
  • 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......
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic