Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling a Servlet in Flash  RSS feed

 
Peter Cuba
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an HTML website that utilizes Servlets. I want to recreate the site using Flash. Is there a way to embed or call a servlet that queries a MS Access database in a Flash developed site? If anyone can direct me to a proper website or assist me in this I would be very appreciative.
[ April 18, 2002: Message edited by: Peter Cuba ]
[ April 22, 2002: Message edited by: Peter Cuba ]
 
johnckendall
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to include more specifics. Where does the database live (client or server)? Are you trying to dynamically access the server data from the client?
 
Rick Salsa
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,
You have to use action script's loadVariables() command. It takes in three parameters, the third optional. Here is a sample:

Have something in your movie trigger this, like a on (release) for a button.
As for you servlet, it needs to write out a plain text response for the flash to take the information in. For example, let's say we've logged in a user and are fetching their first and last name. Your servlet should write out:

Basically, &varName=value. Flash will read this in, and now your movie will have two variables, called firstname and lastname, that you can use in your movie.
I haven't tried this out with a servlet yet, but it should work no problem. I've done this with php and it works no problem. There is a good book called PHP for Flash. The book has a
web site where you can download all the source code and flash files.
If you have any other questions, just post here and I'll try to help as best I can
HTH,
/rick
P.S. Oh yeah. I don't know if you use J2EE, but Flash 6 has a special gateway to work with J2EE app servers. The only problem is that it only works with JRun (talk about vendor lock-in)
 
Pauline McNamara
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter, a quick search on Macromedia's Flash support site gives a link to this tech note:
http://www.macromedia.com/support/flash/ts/documents/java_get.htm
Here's a link to a tutorial for using Servlets with Flash. I've just started looking into this option myself, haven't done the tutorial yet though. http://www.virtual-fx.net/tutorials/html/flashjavaservlets.html
I'd be very interested to hear how you do with this.
Pauline
[ April 23, 2002: Message edited by: Pauline McNamara ]
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rick salsa:
As for you servlet, it needs to write out a plain text response for the flash to take the information in. For example, let's say we've logged in a user and are fetching their first and last name. Your servlet should write out:

Basically, &varName=value. Flash will read this in, and now your movie will have two variables, called firstname and lastname, that you can use in your movie.

Just as a side note, this format is called URLEncoded format. You can pass parameters in this was to Flash just as you'd pass them to a CGI script. I use this exact technique to read a file into Flash for "context-sensitive" links at my website.
When you embed you .swf file, just add a '?' and then the parameter list, like this:

Of course, if you'd rather hide the parameters a little better, you could write them to a file and simply pass the file name to the Flash application.
I hope you find this useful,
Corey
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was a session at JavaOne given by a guy from Macromedia about Flash and J2EE -- you can check you the slides online, you just need to register first (if you haven't already)
Building Next-Generation Web Application Interfaces for the JavaTM 2 Platform, Enterprise Edition (J2EETM)
You can actually watch the session by purchasing a pass through the Java Learning Center
[ April 23, 2002: Message edited by: Jessica Sant ]
 
Peter Cuba
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rick salsa:
Hi Peter,
You have to use action script's loadVariables() command. It takes in three parameters, the third optional. Here is a sample:

Have something in your movie trigger this, like a on (release) for a button.
As for you servlet, it needs to write out a plain text response for the flash to take the information in. For example, let's say we've logged in a user and are fetching their first and last name. Your servlet should write out:

Basically, &varName=value. Flash will read this in, and now your movie will have two variables, called firstname and lastname, that you can use in your movie.
I haven't tried this out with a servlet yet, but it should work no problem. I've done this with php and it works no problem. There is a good book called PHP for Flash. The book has a
web site where you can download all the source code and flash files.
If you have any other questions, just post here and I'll try to help as best I can
HTH,
/rick
P.S. Oh yeah. I don't know if you use J2EE, but Flash 6 has a special gateway to work with J2EE app servers. The only problem is that it only works with JRun (talk about vendor lock-in)
 
Peter Cuba
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pauline McNamara:
Hi Peter, a quick search on Macromedia's Flash support site gives a link to this tech note:
http://www.macromedia.com/support/flash/ts/documents/java_get.htm
Here's a link to a tutorial for using Servlets with Flash. I've just started looking into this option myself, haven't done the tutorial yet though. http://www.virtual-fx.net/tutorials/html/flashjavaservlets.html
I'd be very interested to hear how you do with this.
Pauline
[ April 23, 2002: Message edited by: Pauline McNamara ]

Thanks Pauline. I downloaded that tutorial. It looks like valuable info that might solve my problem. I will let you know about my progress.
Peter
 
Peter Cuba
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone for your input. I am sure you will be hearing from me soon again.
Peter
[ April 24, 2002: Message edited by: Peter Cuba ]
 
Karl Moss
Author
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rick salsa:
P.S. Oh yeah. I don't know if you use J2EE, but Flash 6 has a special gateway to work with J2EE app servers. The only problem is that it only works with JRun (talk about vendor lock-in)

I'm happy to say that this is not so - Flash remoting will work with other app servers as well. I can't give you a specific list, but watch for announcements.
 
Rick Salsa
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Karl Moss:

I'm happy to say that this is not so - Flash remoting will work with other app servers as well. I can't give you a specific list, but watch for announcements.

Hmmm This must be new? I'm on the JRun beta testing team, and they mentioned that this would only work with JRun? I haven't been there in a bit, so maybe this is new?? If that's the case, then it is great news
/rick
[ April 25, 2002: Message edited by: rick salsa ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!