• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JNLP applet to servlet communication problems -Directory Structure

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I have a very basic question regarding the directory structure for deploying an applet through JNLP.Let me explain my requirement.

I have an applet inside src/com/alex and the class files are in bin/com/alex directory.I have jar ed the class files in the bin directory and the applet is successfully launched.It works fine.

Now i have to make the applet-servlet communication working where the servlet will communicate with the database and give values to the applet.

I have a function httptext() in the applet class that will communicate with servlet in the WEB-INF/classes directory.the httptext() needs to import another function that would be sonwhere com/alex.httpmessage.

Now how should i place all my class files and how should i jar it to make it complete .

MenuDemo.java (main applet) is in src/com/alex/
MenuDemo.class(main applet class) is in bin/com/alex

The Function HttpMessage () is used by httptext() in the applet class to communicate with the servlet and in the applet class i have import com.alex.HttpMessage

Where should i place this HttpMessage()?

Any Help is highly appreciated !
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know what it means to "import a function". That isn't a Java feature, but you must mean something in Java when you say that. Perhaps you could explain that differently.

As for how to set up the jar file for your applet, you just put all the class files required by the applet in a jar and make sure that you put the jar in a place where it can be accessed via your HTTP server. That's all. If you are having trouble with that you should create an extremely simple applet with only one class and make sure you know how to deploy that before going on to more complex things.

And as for communicating with a servlet, you're just going to be sending an HTTP request to the URL which represents the servlet to the outside world. Don't think of it as interacting with the class which implements the servlet, because it isn't.
 
alex antony
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.

I have tested launching the applet through jnlp and it works fine.

I have also tested the applet-servlet communication through http which works fine but in that case i have embedded that applet s class file in the html page .

Now where i am lacking is how to include the servlet in the jar file so that the applet that is launched through JNLP communicates with the servlet.

i read some articles and came to know about the jnlp-servlet.jar file and i have included that in the lib of my WEB-INF.

I have tried things but now i am struck up at this point

I have compiled all the classes and jar file looks like this


META-INF/MANIFEST.MF
META-INF/MYSELF7.SF
META-INF/MYSELF7.DSA
META-INF/
com/
com/alex/
com/alex/MenuDemo$MyTableCellRender.class
com/alex/PopupManager$1.class
com/alex/MenuDemo.class
com/alex/MenuDemo$HttpMessage.class
com/alex/MenuDemo$1.class
com/alex/PopupManager.class
com/alex/MenuDemo$2.class
WEB-INF/
WEB-INF/web.xml
WEB-INF/lib/
WEB-INF/lib/jnlp-servlet.jar
WEB-INF/classes/
WEB-INF/classes/DaytimeServlet.java~
WEB-INF/classes/DaytimeServlet.java
WEB-INF/classes/DaytimeServlet.class


my jnlp file is this


<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0+" codebase="http://150.236.9.70:8080/june/" href="alertsys.jnlp">
<information>
<title>Smart Alert Management System</title>
<vendor>ericsson india global Services</vendor>
<homepage href="http://150.236.9.70:8080/june/"/>
<description>Smart Alert Management System</description>
<description kind="short">IN Service Level Monitoring</description>
<offline-allowed />
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+"/>
<![CDATA[
<jar href="alert.jar" />
]]>
</resources>
<application-desc main-class="com.alex.MenuDemo"/>
</jnlp>


But i am getting this error

JNLParseException[ Could not parse launch file. Error at line 0.]
at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Failed to find the '<' charater that marks the end of a CDATA element. Exception parsing xml at line 0
at com.sun.deploy.xml.XMLParser.skipPCData(Unknown Source)
at com.sun.deploy.xml.XMLParser.nextToken(Unknown Source)
at com.sun.deploy.xml.XMLParser.parse(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


Any ideas why this error occurs !

WOuld be really greatful for your help or ideas regards this
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

alex antony wrote:Now where i am lacking is how to include the servlet in the jar file so that the applet that is launched through JNLP communicates with the servlet.



You don't do that. The servlet runs on the server. Do you have a server running yet? Is it configured to run that servlet?
 
alex antony
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i am downloading the jar file from a web server.My server is configured to run servlets.


as far as i read from the articles the applet seeks the help of servlet to communicate with the database.i tried directly connecting to the database but it dint work.But i was able to get the database values if i put a servlet in between..

The reason i am confused is why this doesnt work if i use jnlp to launch it ...I suppose there might be something to do with the jar files but i am not sure .....

I have some jnlp development guides but there are no prior information on how to use servlets within JNLP.

What else approach i can do to make my client JNLP communicate with my server and fetch the db values.

 
alex antony
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that error is resolved....i modified the web.xml file like this



Now the applet is launching fine but only the frame...The applet is still not communicating with the servlet .

if i give hard coded values it is running fine ..but i am not able to fetch values from the database.

 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then there is something wrong with your applet. It's most likely throwing an exception. Open the Java Console and look for stack traces.
reply
    Bookmark Topic Watch Topic
  • New Topic