cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
587
Views
0
Helpful
5
Replies

how to get the requestor phone's device name or ip?

zitop_tech
Level 1
Level 1

when the ip phone request my services, how can i get the phone's device name or ip?

thanks^_^

5 Replies 5

Gergely Szabo
VIP Alumni
VIP Alumni

Hello,

quite easy. Look at the [HTTP] global variables of your applications.

For instance, if your services are PHP-based, then this should help:

http://sk.php.net/manual/en/reserved.variables.php#reserved.variables.server

You are looking for

$_SERVER['REMOTE_ADDR'] or

$_SERVER['REMOTE_HOST']

If ASP, then

Request.ServerVariables("remote_addr") or

Request.ServerVariables("remote_host")

thanks, it works, but in JSP, how can i get the deveicename(i can get the remoteip)?

thanks for advanced.

Google is your best friend ;-)

Those are standard CGI variables, must be available in PHP/ASP(X)/JSP/your-favorite.

Anyway, try this:

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.util.*;

/** Creates a table showing the values of all the CGI variables.

*

* Part of tutorial on servlets and JSP that appears at * http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/ * 1999 Marty Hall; may be freely used or adapted. */ public class ShowCGIVariables extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String[][] variables = { { "AUTH_TYPE", request.getAuthType() }, { "CONTENT_LENGTH", String.valueOf(request.getContentLength()) }, { "CONTENT_TYPE", request.getContentType() }, { "DOCUMENT_ROOT", getServletContext().getRealPath("/") }, { "PATH_INFO", request.getPathInfo() }, { "PATH_TRANSLATED", request.getPathTranslated() }, { "QUERY_STRING", request.getQueryString() }, { "REMOTE_ADDR", request.getRemoteAddr() }, { "REMOTE_HOST", request.getRemoteHost() }, { "REMOTE_USER", request.getRemoteUser() }, { "REQUEST_METHOD", request.getMethod() }, { "SCRIPT_NAME", request.getServletPath() }, { "SERVER_NAME", request.getServerName() }, { "SERVER_PORT", String.valueOf(request.getServerPort()) }, { "SERVER_PROTOCOL", request.getProtocol() }, { "SERVER_SOFTWARE", getServletContext().getServerInfo() } }; String title = "Servlet Example: Showing CGI Variables"; out.println(ServletUtilities.headWithTitle(title) + "\n" + "

" + title + "

\n" + "\n" + "\n" + "
CGI Variable NameValue"); for(int i=0; iNot specified"; out.println("
" + varName + "" + varValue); } out.println("
"); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } }

Thanks for your advices!

maybe the "deveice Name" is not included by CGI variables.

let'me test, thanks a lot

The standard way to get the device name is to make the phone append it when making the first request to a service..

http://your-application-server/path/myapplication?device=#DEVICENAME#

Then you get that variable and store it in a session variable. There's really almost never a need to go by IP.