AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Instantiating Servlets at runtime

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming
View previous topic :: View next topic  
Author Message
Alex
Guest





PostPosted: Sun May 22, 2005 12:41 am    Post subject: Instantiating Servlets at runtime Reply with quote



Hi,

I am trying to build a webapp with servlets that runs several games
concurrently. I was hoping to have each seperate game run in the background
by a seperate servlet instance, where requests are forwarded to the
instances by a GameMaster servlet.

It would be possible to do this if there were a fixed number of games, by
simply naming Game1 - Game6 in web.xml, but I was hoping to let games be
created and ended on-the-fly and I don't know if this is possible.

Does anyone have any suggestions?

I probably haven't made much sense above so I will include a paragraph from
www.acknowledge.co.uk which explains what I am trying to do, but only with a
fixed number of games:

"There is one servlet instance per registered servlet name. But why? Well
say you have a servlet class that is a front end to a game called Vengance
that is played over the Internet. Vengance is a multiplayer game that can be
run in either death match mode or team match mode. The Vengance servlet uses
initialisation parameters to determine which mode the game should be played
in. Although we have one Vengance servlet class, we need two servlet
instances. We name one servlet instance DeathMatchVengance and the other
TeamMatchVengance. They are two totally different games, two totally
different servlets, that are accessed by two totally different sets of
players. In short we need two different servlets that are instantiated from
the same servlet class. We can achieve this by registering the Vengance
servlet class under two different names. Also we configure these two
Vengance servlet instances take different initialisation parameters, one for
team match mode and the other for death match mode. Hence, the reality is
one servlet instance per registered servlet name."

Thanks for your help,
Alex


Back to top
Juha Laiho
Guest





PostPosted: Sun May 22, 2005 8:26 am    Post subject: Re: Instantiating Servlets at runtime Reply with quote



"Alex" <yeh (AT) right (DOT) com> said:

(people at Right Management Consultants, Philadelphia, must be happy
about your choice of fake domain name - when creating fakes, use
such that end with ".invalid", and will not become valid domain names
even with the ".invalid" removed)

Quote:
I am trying to build a webapp with servlets that runs several games
concurrently. I was hoping to have each seperate game run in the background
by a seperate servlet instance, where requests are forwarded to the
instances by a GameMaster servlet.

It would be possible to do this if there were a fixed number of games, by
simply naming Game1 - Game6 in web.xml, but I was hoping to let games be
created and ended on-the-fly and I don't know if this is possible.

Does anyone have any suggestions?

Write your game first so that it isn't dependent on servlets. Just
create some interface through which commands can be entered; this
interface should also handle the issues of distinguishing several games.
You'll anyway have to store the game situation data somewhere (in a
database?), so design your data store in such a way that it'll be easy
to add/remove instances of game data.

After that, write a servlet frontend through which commands can be
entered. This servlet frontend will apparently need some data storage
of its own, for maintaining the player/game data.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)

Back to top
Alex
Guest





PostPosted: Sun May 22, 2005 10:57 am    Post subject: Re: Instantiating Servlets at runtime Reply with quote



"Juha Laiho" <Juha.Laiho (AT) iki (DOT) fi> wrote

Quote:
"Alex" <yeh (AT) right (DOT) com> said:

(people at Right Management Consultants, Philadelphia, must be happy
about your choice of fake domain name - when creating fakes, use
such that end with ".invalid", and will not become valid domain names
even with the ".invalid" removed)

Point taken :-P

Quote:
I am trying to build a webapp with servlets that runs several games
concurrently. I was hoping to have each seperate game run in the
background
by a seperate servlet instance, where requests are forwarded to the
instances by a GameMaster servlet.

It would be possible to do this if there were a fixed number of games, by
simply naming Game1 - Game6 in web.xml, but I was hoping to let games be
created and ended on-the-fly and I don't know if this is possible.

Does anyone have any suggestions?

Write your game first so that it isn't dependent on servlets. Just
create some interface through which commands can be entered; this
interface should also handle the issues of distinguishing several games.
You'll anyway have to store the game situation data somewhere (in a
database?), so design your data store in such a way that it'll be easy
to add/remove instances of game data.

After that, write a servlet frontend through which commands can be
entered. This servlet frontend will apparently need some data storage
of its own, for maintaining the player/game data.

If the games are not servlets then it would become quite difficult to make
them render pages. I would have to pass all the reqest, response, context,
session, printwriter etc. objects to each one; or am I making this far more
complicated than it should be?

Thank you from you help

Alex



Back to top
Juha Laiho
Guest





PostPosted: Sun May 22, 2005 5:02 pm    Post subject: Re: Instantiating Servlets at runtime Reply with quote

"Alex" <yeh (AT) right (DOT) invalid> said:
Quote:
"Juha Laiho" <Juha.Laiho (AT) iki (DOT) fi> wrote in message
news:d6pfmr$fcd$3 (AT) ichaos (DOT) ichaos-int...
"Alex" <yeh (AT) right (DOT) com> said:
I am trying to build a webapp with servlets that runs several
games concurrently. I was hoping to have each seperate game run in
the background by a seperate servlet instance, where requests are
forwarded to the instances by a GameMaster servlet.
....
Write your game first so that it isn't dependent on servlets.
....
After that, write a servlet frontend through which commands can be
entered. This servlet frontend will apparently need some data storage
of its own, for maintaining the player/game data.

If the games are not servlets then it would become quite difficult to make
them render pages. I would have to pass all the reqest, response, context,
session, printwriter etc. objects to each one; or am I making this far more
complicated than it should be?

I think you're seeing this more complex than it needs.

From the perspective of the game engine, the way to get the commands and
to display the output should have very little effect. So, plainly in the
context of your game, think what is the input the game engine needs
(and what is the context that needs to be maintained somewhere outside
the game engine to store the "game world"). Arrange for the input layer
to be able to provide the needed data, and some way to identify the
context to which this input data is related.

Similarly, the display code shouldn't need the game logic - it just needs
to somehow get the information on what to display. Think on what data is
needed to present the display to the user - and provide the display layer
some way to get to that data. Espeially as you're thinking of a web-based
solution, you pretty much have to create each new display from scratch;
you cannot just "clear a character/pixel from position p, and show
a charaxter/pixel at position p2".
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)

Back to top
kjc
Guest





PostPosted: Sun May 22, 2005 5:38 pm    Post subject: Re: Instantiating Servlets at runtime Reply with quote

Alex wrote:
Quote:
Hi,

I am trying to build a webapp with servlets that runs several games
concurrently. I was hoping to have each seperate game run in the background
by a seperate servlet instance, where requests are forwarded to the
instances by a GameMaster servlet.

It would be possible to do this if there were a fixed number of games, by
simply naming Game1 - Game6 in web.xml, but I was hoping to let games be
created and ended on-the-fly and I don't know if this is possible.

Does anyone have any suggestions?

I probably haven't made much sense above so I will include a paragraph from
www.acknowledge.co.uk which explains what I am trying to do, but only with a
fixed number of games:

"There is one servlet instance per registered servlet name. But why? Well
say you have a servlet class that is a front end to a game called Vengance
that is played over the Internet. Vengance is a multiplayer game that can be
run in either death match mode or team match mode. The Vengance servlet uses
initialisation parameters to determine which mode the game should be played
in. Although we have one Vengance servlet class, we need two servlet
instances. We name one servlet instance DeathMatchVengance and the other
TeamMatchVengance. They are two totally different games, two totally
different servlets, that are accessed by two totally different sets of
players. In short we need two different servlets that are instantiated from
the same servlet class. We can achieve this by registering the Vengance
servlet class under two different names. Also we configure these two
Vengance servlet instances take different initialisation parameters, one for
team match mode and the other for death match mode. Hence, the reality is
one servlet instance per registered servlet name."

Thanks for your help,
Alex


Wrong model.

Use an applet.

Back to top
Alex
Guest





PostPosted: Sun May 22, 2005 6:54 pm    Post subject: Re: Instantiating Servlets at runtime Reply with quote

"Juha Laiho" <Juha.Laiho (AT) iki (DOT) fi> wrote

Quote:
From the perspective of the game engine, the way to get the commands and
to display the output should have very little effect. So, plainly in the
context of your game, think what is the input the game engine needs
(and what is the context that needs to be maintained somewhere outside
the game engine to store the "game world"). Arrange for the input layer
to be able to provide the needed data, and some way to identify the
context to which this input data is related.

Similarly, the display code shouldn't need the game logic - it just needs
to somehow get the information on what to display. Think on what data is
needed to present the display to the user - and provide the display layer
some way to get to that data. Espeially as you're thinking of a web-based
solution, you pretty much have to create each new display from scratch;
you cannot just "clear a character/pixel from position p, and show
a charaxter/pixel at position p2".

I think I see what you mean: I need a servlet to handle the user input
which interprets it and call the appropriate commands in the correct game
engine instance. The engine updates a 'game state' stored somewhere and the
orginal (or perhaps a different) servlet interprets the game state and
simply 'draws' it.

Thank you.
Alex



Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.