当前位置:网站首页>Using request headers to develop multi terminal applications
Using request headers to develop multi terminal applications
2022-07-05 09:11:00 【The corner of fufu】
servlet page
package com.ssyt.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** * Servlet implementation class UserAgentServlet */
@WebServlet("/ua")
public class UserAgentServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/** * @see HttpServlet#HttpServlet() */
public UserAgentServlet() {
super();
// TODO Auto-generated constructor stub
}
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String userAgent = request.getHeader("User-Agent");
response.setContentType("text/html;charest=utf-8");
response.getWriter().println(userAgent);
String output="";
if(userAgent.indexOf("Windows NT")!=-1) {
output = "<h1>This is PC!</h1>";
}else if(userAgent.indexOf("iPhone")!=-1 || userAgent.indexOf("Android")!=-1) {
output = "<h1>This is Mobile!</h1>";
}
response.getWriter().println(output);
}
}
Web effect
PC End
Mobile
边栏推荐
- Kubedm series-00-overview
- Ecmascript6 introduction and environment construction
- [daiy4] copy of JZ35 complex linked list
- Jenkins Pipeline 方法(函数)定义及调用
- Array, date, string object method
- Characteristic Engineering
- Codeworks round 639 (Div. 2) cute new problem solution
- 编辑器-vi、vim的使用
- [technical school] spatial accuracy of binocular stereo vision system: accurate quantitative analysis
- C # draw Bezier curve with control points for lattice images and vector graphics
猜你喜欢
Introduction Guide to stereo vision (3): Zhang calibration method of camera calibration [ultra detailed and worthy of collection]
Svg optimization by svgo
Applet (subcontracting)
Creation and reference of applet
Add discount recharge and discount shadow ticket plug-ins to the resource realization applet
[technical school] spatial accuracy of binocular stereo vision system: accurate quantitative analysis
C#【必备技能篇】ConfigurationManager 类的使用(文件App.config的使用)
Applet data attribute method
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
Programming implementation of ROS learning 5-client node
随机推荐
Solution to the problems of the 17th Zhejiang University City College Program Design Competition (synchronized competition)
太不好用了,长文章加图文,今后只写小短文
What is a firewall? Explanation of basic knowledge of firewall
牛顿迭代法(解非线性方程)
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
Codeworks round 681 (Div. 2) supplement
kubeadm系列-01-preflight究竟有多少check
Multiple linear regression (gradient descent method)
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition
Editor use of VI and VIM
uni-app 实现全局变量
Applet (subcontracting)
Node collaboration and publishing
Nodemon installation and use
Introduction Guide to stereo vision (2): key matrix (essential matrix, basic matrix, homography matrix)
Summary of "reversal" problem in challenge Programming Competition
fs. Path module
2311. 小于等于 K 的最长二进制子序列
Explain NN in pytorch in simple terms CrossEntropyLoss
交通运输部、教育部:广泛开展水上交通安全宣传和防溺水安全提醒