• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can you start an application on the server by calling a servlet

 
David Duffy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am taking a java web programming class and we have an assignment to write a servelet that when called will open a gui on the server to allow anyone sitting on the server to paste text into. The text pasted in the text field will then be formatted and returned to the original callers web browser.

What I'm wondering is, is it is possible to make a call to a servlet that will cause another application (which will be a gui) to open on the server macine?

Thanks for any insight you can offer.

DLD
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it too late to get your money back for this class?

Seriously, the container would need to be running under a user that has access to the screen. Not typical on a Unix system. Probably wouldn't work if running as a windows service either.

Look at Runtime.exec
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html

It allows you to call external processes from a Java program and accept that process's output.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it too late to get your money back for this class?


Seriously! It's hard to imagine an assignment with less applicability to real-world problems.
[ October 15, 2005: Message edited by: Bear Bibeault ]
 
David Duffy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the problem that it solves for the Prof is one in which he has 2 systems sitting on his desktop one a mac and the other a pc. If he wants to transfer some text from the mac to the pc very quickly and easily he starts the servlet it opens a GUI on the mac pastes the text and then returns. No need to ftp or copy file or rewrite text.

I also think this is an exercise in here's what I did lets see if you can do it too.

Straying from the merits of the exercise back to the topic, I looked at the runtime link you provided Ben and added some code to my doPost to open a test app that I have with a gui but I get returned an EXCEPTION_ACCESS_VIOLATION.

here's a code snippet inside my doPost method


I'm doing all of this on my local machine with admin privelges. Is there something else I need to add to execute an app as a specified user?

Thanks for your assistance.
 
Eddy Lee Sin Ti
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of GUI your servlet going to invoke? Must it be another external application?

Perhaps you can just develop a simple Swing-based window that serves as the input screen at the server and running within the execution context of the servlet. What you need to do then is just pass the value back from the window to stream back to the client
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either way, it's a question of screen ownership.
Under any real, multi-user system (which includes Mac OSX) there is a good likelyhood that the user under which Tomcat is running will not be the same user under which the GUI is running.

If, for the sake of the exercise, the teacher will insure that Tomcat is started user the same user that started the GUI, either approach, might work (I think). You would have to try it.

Which version of Mac will your teacher be running?
Will you have access to that OS to build and test this app?
 
David Duffy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for your assistance! I figured out the problem that I was having and Ben had it right on the money. When I looked more closely at the Tomcat service properties in windows the 'Allow service to interact with desktop' checkbox was unchecked. After I checked it I could do what I had been trying to do all along.

Thanks again for your help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic