当前位置:网站首页>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
边栏推荐
- Talking about label smoothing technology
- location search 属性获取登录用户名
- Kubedm series-00-overview
- Applet global style configuration window
- Beautiful soup parsing and extracting data
- TF coordinate transformation of common components of ros-9 ROS
- Introduction Guide to stereo vision (6): level constraints and polar correction of fusiello method
- Multiple linear regression (sklearn method)
- Wxss template syntax
- scipy.misc.imread()
猜你喜欢

容易混淆的基本概念 成员变量 局部变量 全局变量
![[beauty of algebra] singular value decomposition (SVD) and its application to linear least squares solution ax=b](/img/ee/8e07e2dd89bed63ff44400fe1864a9.jpg)
[beauty of algebra] singular value decomposition (SVD) and its application to linear least squares solution ax=b

Programming implementation of ROS learning 6 -service node

Blogger article navigation (classified, real-time update, permanent top)

混淆矩阵(Confusion Matrix)

Programming implementation of subscriber node of ROS learning 3 subscriber

Summary of "reversal" problem in challenge Programming Competition

牛顿迭代法(解非线性方程)

Applet customization component

Generate confrontation network
随机推荐
[Niuke brush questions day4] jz55 depth of binary tree
Use arm neon operation to improve memory copy speed
Applet network data request
How many checks does kubedm series-01-preflight have
.NET服务治理之限流中间件-FireflySoft.RateLimit
Priority queue (heap)
Programming implementation of ROS learning 6 -service node
Array, date, string object method
[code practice] [stereo matching series] Classic ad census: (4) cross domain cost aggregation
深入浅出PyTorch中的nn.CrossEntropyLoss
C#绘制带控制点的Bezier曲线,用于点阵图像及矢量图形
MPSoC QSPI Flash 升级办法
[beauty of algebra] singular value decomposition (SVD) and its application to linear least squares solution ax=b
C # draw Bezier curve with control points for lattice images and vector graphics
Introduction Guide to stereo vision (6): level constraints and polar correction of fusiello method
2311. Longest binary subsequence less than or equal to K
交通运输部、教育部:广泛开展水上交通安全宣传和防溺水安全提醒
AdaBoost use
Codeforces Round #648 (Div. 2) D. Solve The Maze
2309. 兼具大小写的最好英文字母




