how to get request url in node js

Ads
 

how to get request url in node js

Hi,

I want to get the request url in Node js.

how to get request url in node js?

Thanks

View Answers

February 12, 2019 at 5:49 AM

Hi,

Node js is server side programming language and it uses chrome JavaScript engine to run server-side JavaScript.

So, you can use the JavaScript code to get the url of request.

how to get request url in node js?

Here is the code:

console.log("URL: "+request.url);

Here is full code example:

var http = require('http');

var port = 8081;

var s = http.createServer();
s.on('request', function(request, response) {
    response.writeHead(200);
    console.log("Method: "+request.method);
    console.log(request.headers);
    console.log("URL: "+request.url);
    response.write('Hello Node JS..');
    response.end();
});

s.listen(port);
console.log('Browse to http://127.0.0.1:' + port);

Thanks

Ads









Related Tutorials/Questions & Answers:
How to send the request and get the request?
How to send the request and get the request?  how to send a request to a JSP file in another domain in the same server and get the request done i.e how to include JSP file of one domain to another doamin JSP within in the same
How to get the request scope values? - Struts
How to get the request scope values?  Get value in Struts
Advertisements
java how to get domain name from url
java how to get domain name from url  How to get the domain name from a url string? Example program in java for "how to get domain name from url" Thanks   Hi, You can use the following example code: URL linkURL
how to get HTTP GET request value using javascript
how to get HTTP GET request value using javascript  how to get HTTP GET request value using javascript   how is how you can get HTTP GET request value using javascript: var parameter = window.location.search.replace
How to send URL in Post request from local server to remote server?
How to send URL in Post request from local server to remote server?  ... server(using Tomcat). Now i want: 1> How to establish a Connection to another server remotely?What to do in code??? 2> How to send a Post Request
How to get country locale from a http request
How to get country locale from a http request  Hi, I Have a requirement like , i need to get the country locale(from whcih country he is logged... to implement business logic. Can anyone help me out to get this done. any help
How can I get the full URL with the attached parameters? - JSP-Servlet
How can I get the full URL with the attached parameters?  Hi, I'm trying to figure out how to get the current url and use it in my jsp page. I...:8080/MesEduSchoolsProject/displayMenu.jsp How can I get the full URL with the attached parameters
Example of Getting request URL in a servlet
Example of Getting request URL in a servlet  One servlet can be configured to handle a set of requests. So, in Servlet you have to get the URL of the page accessed. How you can get the URL of the page accessed in the Servlet
How to Get Referer URL Servlet
How to Get Referer URL Servlet In this section we will discuss about getting the referer url in Java. This example explains you how to get the referer url... a simple example which will demonstrate you about how to get the referer url
Java Servlet : Get URL Example
Java Servlet : Get URL Example In this tutorial, You will learn how to get url... getRequestURL() method to get current URL. GetURLExample.java package... the requested client URL. It returns the current URL which containing protocol
Configure Js request in Web.xml
Configure Js request in Web.xml  Hi all, I have 1 basic doubt,suppose i have 2 jsp,1 servlet,1 web.xml file.i need to redirect 1 page via servlet... .If it's Explain how do i it.(using apache tomcat) <html> <head> <meta
How Can I get ArrayList of Data from jsp with ajax request
How Can I get ArrayList of Data from jsp with ajax request  Hi, I... response. But I don't how how can reterve this dynamic 5 employee records to struts action class. Plese tell me how to send this 5 employee record table
How to send request to the visa/master card to get verifed the credit card - Security
How to send request to the visa/master card to get verifed the credit card  Sending request to verify the card number
How to send request to the visa/master card to get verifed the credit card - Security
How to send request to the visa/master card to get verifed the credit card  we are accepting the credit card number, So how to forward request get verified the card number. Thanks You
Get current page URL from backing bean
Get current page URL from backing bean  How to get current page URL from backing bean
Request URl using Retrive data from dtabase
Request URl using Retrive data from dtabase  Using With GWT the user... the contents from the db based on the event id. But this jsp url should be a public url. Means anyone can access it directly. ( something like
JSP Get URL
JSP Get URL          JSP Get URL is used to get the url of the current... illustrate an example from 'JSP Get URL'. To understand the example we create
Java get Node Text
Java get Node Text     ... code, we want to describe you how to obtain the text of the node in the java...;employee.xml".In order to get the text of the node specified in a XML file, we
Java get Node Value
Java get Node Value       In this section, you will learn how to obtain the node value...()- This method allows direct access to the child node that is the root element
How to send request to the visa/master card to get verifed the credit card - Security
How to verifed the credit card  Can anyone please explain me ...how to verify the card number while accepting payment online
How to capture screenshot in url?
How to capture screenshot in url?  Hi, How to capture screenshot and it will store the capture image in url like this http://localhost/xxx/yyy/ it wil not sore C:\ or D:\ it should store like this http://localhost/xxx/yyy
How to do url rewritting?
How to do url rewritting?  Dear Sir/Mam I have this link http://localhost:8085/call4admission/admin/home/Admin_Profile.jsp?pn=1 i want to change the link to http://localhost:8085/call4admission Ho
How to store url path?
How to store url path?  Image is stored in physical directory like this String file = "C:/xampp/htdocs/jobqueen/" + username + createTimeStampStr() + ".PNG"; this physical directory is working fine but I want store in url
How to send HTTP request in java?
How to send HTTP request in java?  How to send HTTP request in java
HOW TO USE REQUEST DISPATCHER - Servlet Interview Questions
HOW TO USE REQUEST DISPATCHER  PLEASE USE A BUSINESS CODES TO EXPLAIN HOW TO USE REQUEST DISPATCHER, SESSION MANAGEMENT AND URL REWRITING. AND USE MSSQL DATABASE TO SAVE THE DATA THANKS FOR YOUR SOLUTION IN ADVANCE
How JSP Forwards a request
How JSP Forwards a request       In this section you will study how jsp forwards a request.  The <jsp:forward>  forwards the request information from one resource
How to open URL in iPhone SDK
How to open URL in iPhone SDK  In my iPhone application ..i wanted to open a url in the application. Is it possible? If yes how will i come back to my application
how to display response in request page
how to display response in request page  Sir/Mom, My request page have three text boxes. Enter register number in the first box then click the submit button.This time shows the name and mark to display the second and third boxes
How to store url path in file ?
How to store url path in file ?  Hi, How to store url path in file ? this my program public class Image implements Runnable..."; This is store phiscal directory but i want store url path like
How do i create the node for target SMO in java..???
How do i create the node for target SMO in java..???  How do i create the node for target SMO in java..??? or else whats the method for accessing the target SMO
How to print a webpage without url and date in jsp ?
How to print a webpage without url and date in jsp ?  How to print a webpage without url and date in jsp

Ads