473,785 Members | 2,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to run it on live server to make, a live webserver to a particular port

17 New Member
If I have a WebServer.java file, then after compile to WebServer.class , and upload to server, how to run it on live server to make, a live webserver to a particular port? run localhost success... I must do a JSP and run it from it? how?
Aug 19 '10 #1
9 2616
Dheeraj Joshi
1,123 Recognized Expert Top Contributor
You can use scriplet tag in JSP to run your java code.

Regards
Dheeraj Joshi
Aug 19 '10 #2
Leonidas Savvides
17 New Member
My networking textbook says(4th/e kurose/ross)
prog assignment
In the first stage, you will write a multi-threaded server that simply displays the contents of the HTTP request message that it receives. After this program is running properly, you will add the code required to generate an appropriate response.
............... ..
After your program successfully compiles, run it with an available port number(?), and try contacting it from a browser.To do this, you should enter into the browser's address text box the IP address of your running server. For example, if your machine name is host.someschool .edu, and you ran the server with port number 6789, then you would specify the following URL:

http://host.someschool.edu:6789/

As SAID : In the first stage, you will write a multi-threaded server that simply displays the contents of the HTTP request message that it receives.
I RUN IT localhost and when a request FROM BROWSER
http://localhost:6789/new2.html
appeared in CLI(SERVER) the header, how to this remotely/live server as textbook refers? where view server output stage-1 of assignment localhost=appea r in CLI??
Aug 20 '10 #3
Leonidas Savvides
17 New Member
In a multithreated webServer, each file in the requested.html (main.html, gifs.gif,jpegs. jpeg) are each a separate threat?
Aug 20 '10 #4
chaarmann
785 Recognized Expert Contributor
Read about java socket programming.
Then write the code to listen on (and write to) given port.
Make sure the port isn't blocked by your firewall!

First, develop the single-tread application. Later on, transform it to a much more complicated multithread-application!
Aug 23 '10 #5
Leonidas Savvides
17 New Member
Yes I did that,

I RUN IT localhost success, and when a request FROM BROWSER for url:
http://localhost:6789/new2.html
done, appeared in CLI(SERVER running) the header, how to: this remotely/live server as textbook refers? where view server output stage-1 of assignment in live server HENCE IN localhost=appea r in CLI??
Aug 23 '10 #6
chaarmann
785 Recognized Expert Contributor
You asked:
where view server output stage-1 of assignment in live server HENCE IN localhost=appea r in CLI??
You can display the output on your webserver in your shell or Windows-command-box (DOS-Box) with the Java command System.out.prin tln("my Answer"). (Is it that what you mean with CLI? CLI could be abbreviation for Command Line Interface. (Greetings from Amiga!) Or do you want to store the output in database? because CLI is also an abbreviation for Call Level Interface, a Standard-API for database).
You said CLI and server, but it's very unlikely that you really mean what you said. Because if you make an inquiry by browser, it makes more sense to show the answer inside the browser on the client machine (and not on the server).
To show the answer, you must send back a response on the openend port which is connected to the browser. You need to send back HTML-text. For example:
Expand|Select|Wrap|Line Numbers
  1. Content-type: text/html
  2.  
  3.   <html>
  4.       <head>
  5.           <title>My Title</title>
  6.       </head>
  7.       <body>
  8.           My answer 
  9.       </body>
  10.   </html>
  11.  
Of course you can read in this text from a file (named for example "answer.htm l") instead of hardcoding it in your server program.

Please be sure about the meaning of technical Terms before using them and then please make short, understandable English sentences. I had a lot of problems to understand what you mean.

Or just list your source code here, then it also becomes more clear what you mean.
Aug 24 '10 #7
Leonidas Savvides
17 New Member
If I solve this, I think I will make it all others:
Expand|Select|Wrap|Line Numbers
  1. class TCPServer {
  2.     public static void main(String argv[]) throws Exception
  3.         {
  4.                String clientSentence;
  5.                ServerSocket welcomeSocket = new ServerSocket(6789);
  6.                while(true) {
  7.                 Socket connectionSocket = welcomeSocket.accept();
  8.  
  9.                 BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream( ) ) );
  10.  
  11.                 clientSentence = inFromClient.readLine();
  12.  
  13.                    System.out.println("RECEIVED FROM CLIENT : " + clientSentence + "\n");
  14.             }
  15.         }
  16. }
  17.  
insert in browser http://localhost:6789/new.html
appear in Command Line(in live server where appear?):
Expand|Select|Wrap|Line Numbers
  1. C:\Users\User\Documents\TextBooksDataFiles\RexPractice\JAVA\ZIPs\jhtp7_SSM_ch24solutions\te
  2. st\WebServer\aw\P11-ch2>java TCPServer
  3. RECEIVED FROM CLIENT : GET /new.html HTTP/1.1
how run server class file in live server and see results?
Aug 24 '10 #8
chaarmann
785 Recognized Expert Contributor
you asked:
how run server class file in live server and see results?
Why do you ask? You have already done exactly that.
You run your server class file in live server with command "java TCPServer". And you have seen the result. The result, as you have listed it, was "GET /new.html HTTP/1.1".
So what's your problem? I can only guess. Maybe you want to show the result in browser? Then just extend your code instead of just putting out the filename "new.html" with println(): read the text from new.html and send it as answer over the current socket back to the browser! (see also previous reply).
That means first you have to parse the result (which is stored in variable "clientSentence ") and grab the file name (in this case "new.html") . Then you open this file from disk and read in all its text which you store into a string. Then you send this string back over the socket.
Aug 24 '10 #9
Leonidas Savvides
17 New Member
please note by saying live I mean REMOTE SERVER not localhost...wel l?
Aug 24 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2166
by: Dave Smithz | last post by:
Hi There, I have taken over someone else's PHP code and am quite new to PHP. I made some changes and have implemented them to a live environment fine so far. However, I now want to setup a test environment. All the PHP scripts start with a few lines of: require_once "library file at specific location on server"
2
1979
by: Bozo | last post by:
Hi, Does anyone know how to run a .Net exe using a particualr port number to connect to a web service? How do you do this programmatically. Thanks
3
1519
by: ChrisAndTammyHallum | last post by:
I have a VB.NET web project that I wrote on my computer with Studio. It works great, on my computer. However when I ported it over to my company's production server it doesn't know how to handle the codebehind. Other programmers have written NET pages using Matrix, which puts everything in 1 file instead of splitting it up, and they work fine. I tried merging my Studio's aspx and vb files into one but it didn't work. Does anyone have an...
2
2261
by: Stephen Brown | last post by:
We've been using dotNet for a couple of years now and have been updating our live server by just overwriting (Explorer drag and drop) the aspx and assembly files until we had some errors reported to us a couple of months ago that some clients received application server errors at the moment we updated (if I remember correctly, they were sharing or process in use errrors). Since then, we've been paranoid about ensuring that there is no...
3
1425
by: Ben Fidge | last post by:
I use the session_end in global.asax to perform clean-up of a temporary shopping cart table. Shoppping Cart items are stored with a session id in the table, and when a session ends a small rountine checks the shopping cart table and deletes any stray items. This has worked a treat for weeks but stopped working today when I uploaded news dlls and aspx pages to the live server using FTP. Nothing has changed code-wise and all relevant...
3
1498
by: | last post by:
I'm trying to create a project on a virtual server that runs on port 8000, rather than port 80. I tried creating the project at http://localhost:8000/MyFolder but it keeps telling me that the file path doesn't map to the url. Is there some trick to using different port numbers? Thanks. Jerry
1
1362
by: enggwaqas | last post by:
I have downloaded a simple port blocker written in vb.net which is working fine, now i want to extend it so that it will display a popup window whenever any application trying to access the particular port blocked by this program... e.g. port 8080 is blocked, when some one try to make request on internet explorer http://testweb:8080/ then it will display a popup which say's IE is trying to access the internet.... Zone Alram is a good example...
2
4560
by: niraan | last post by:
Hi guys, am new to rails and now am doing a project in rubyonrails. for development purpose i have use instant rails. Now i need to upload my project to the live server. i have register the domain name as well as hosting. how can i upload my project to the live server? pls help meee. its very very urgent. i have the cpanel account now and there is a rubyjem. but i do not know how to put my rails application live. pls help meee.
24
8558
TheServant
by: TheServant | last post by:
Hey guys, I used this free tutorial on how to make a live server clock. I did, but a) doesn't work (not too worried, I am sure I can fix this) and b) it out puts the clock to a input text field?! I want it to be in just a normal text display? The core code: <!-- function startclock() { var server_time = new Date();
2
7779
by: amskape | last post by:
I created a script where a user can select from a variety of shipping options for an order from within a jQuery dialog box. The shipping rates are delivered via UPS & FedEx. Oddly enough, the script works fine on my development machine, but on the live server, Firebug returns a "500 Internal Server Error" Here is what my jQuery looks like: jQuery("#select-shipping").click(function(){ // Open the dialog, start with the "loading...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.