Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] Beginners question about server-side scripts

Started by Luka K Mar 10, 2007 at 8:03 PM 1 replies 950+ views
Original Post
Luka K
Luka K
I write one application in java (it takes picture, draw something and display it). It works when I call it like "java -jar xxx.jar". I need to put it on web, but I also need to offer a client to choose on web site, for example (draw triangle, draw rectangle, draw circle). So when client come to my web page he choose one polygon which he wants to be drawn. Now I need something witch will call my application and give it the client choice. It would be good if my application is shown in new window. This shouldn't be big problem, but with this kind of problem I'm totaly beginner and any help would be useful. Luka
markr
markr
In order to run a Java application in the web, it needs to be an Applet. This is different from a standalone application and will require modification to the code.

Parameters can (I think) be passed in via HTML for the Applet code to read and change its behaviour accordingly.

Why not just draw the polygon on the server-side and serve that to a conventional web browser (without requiring client-side Java code or anything else) ?

Mark
ToohrVyk
ToohrVyk
So, suppose your server is http://myserver.com, and the client requests an image from http://somewhereelse.com/image.png. Since the client is a java applet, it requires authorization to fetch data from any other web site than the one it came from. So, you want to send the request to your very own http://myserver.com server. We'll assume that the URL of the required image is sent as GET parameter, such as:

http://myserver.com/getimage/?id=http://somewhereelse.com/image.png

So, your server has a directory named getimage, which contains an index.php, index.asp or some similar script, which takes an "id" argument containing an URL to a remote image, reads that image from wherever it is, and sends it back to the user.

So, choose your server-side programming language of choice and write a script that:
  1. Reads the 'id' GET argument, checks that it is an image (.png, .jpg, .gif)
  2. Downloads the data for the file from the internet using CURL, HttpRequest or some similar library.
  3. Sends the downloaded data to the user as a result.




Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.