Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 20th, 2005, 02:06 PM
Registered User
 
Join Date: Sep 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can I call a servlet from a JFram

Hi,

All I want to know that can I call a servlet from a JFrame or in general from a stand alone application instead of calling form a browser.

I have seen many applications which receive data...i.e details from Internet web sites...from a stand alone application can we also do from a JFrame or a just a Frame application.

If possible just provide me how it can be done....

is it possible to to do witu URL class???

Expecting reply
regards
Vamshi

 
Old September 22nd, 2005, 11:54 AM
Registered User
 
Join Date: Sep 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes it can be done,
creat a new URL object and pass teh path of your web application as parameter:

URL url = new URL("http://127.0.0.1:8080/WEBAPPLICATION(OR COMPLETE PATH TO THE SERVLET YOU ARE CALLING");

firas

 
Old September 23rd, 2005, 12:56 PM
Registered User
 
Join Date: Sep 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you firas.
I have asked many about this a I had not received a proper reply. Yes I will call the servlet in this way. Do I need to set the setContentType("text/html)--:to some thing other than this. If so please reply with parameters to be passed to the setContent Menthod.

Thank you again as this information is very usefull for me.
Regards
Vamshidhar M T

 
Old September 23rd, 2005, 09:15 PM
Registered User
 
Join Date: Sep 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

setContentType(); is a signal to the browser to tell what is coming, i understood you are doing a stand alone application. if you are trying to create your own browser with special features and can recognize the content type then yes you have to tell it. however if your stand alone application is only try to access the server to do some work to your web application so there is no need to that, you can rerurn what ever you want as long as your application knows what is getting.

Firas

 
Old September 25th, 2005, 10:00 PM
Registered User
 
Join Date: Sep 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Firas,

Thank you for U R immediate reply and taking concern abt the issue.

U have posted the reply what exactly I was looking for.
Here I have some more doubts in the same concern.
1. What if I have a small login JDialogBox which will ask for a user name and password. Aftre which I send the details to a Servlet by calling the URL constructor... and then I want a small result to be sent back to the client can I do it???
2.In the above regar can I use RMI instead of Servlet calling using a URL(). Which one is appropriae here???

Regards
Vamshidhar


 
Old September 26th, 2005, 12:52 PM
Registered User
 
Join Date: Sep 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

1- yes.
2- yes, which one is appropriate? the answer depends on what you are doing and type of connection. if this is a client-server application you can use rmie, if you are feeding a web application through yours then you can use EJBs so what you feed through your application will be fed to the web application.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Servlet Call Applet azimdgreat Servlets 2 July 16th, 2008 05:48 AM
servlet call using hyperlink tusharkale Servlets 4 October 3rd, 2007 06:02 AM
servlet shiveka Servlets 1 October 9th, 2006 08:26 PM
Need help in servlet arunj82 Apache Tomcat 0 March 15th, 2006 07:16 AM
How Can I call a HTML file from a servlet? alf.guzman Servlets 3 January 24th, 2005 04:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.