当前位置:网站首页>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
- My experience from technology to product manager
- Applet customization component
- Add discount recharge and discount shadow ticket plug-ins to the resource realization applet
- 3D reconstruction open source code summary [keep updated]
- Solution to the problems of the 17th Zhejiang University City College Program Design Competition (synchronized competition)
- Golang foundation -- map, array and slice store different types of data
- Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
- Luo Gu p3177 tree coloring [deeply understand the cycle sequence of knapsack on tree]
- 2311. Longest binary subsequence less than or equal to K
猜你喜欢
![一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]](/img/c4/27ae0d259abc4e61286c1f4d90c06a.png)
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]

Applet (subcontracting)

Applet (use of NPM package)

Shutter uses overlay to realize global pop-up

Applet (global data sharing)

TF coordinate transformation of common components of ros-9 ROS

微信H5公众号获取openid爬坑记

Wechat H5 official account to get openid climbing account

Nodemon installation and use

Understanding rotation matrix R from the perspective of base transformation
随机推荐
Introduction Guide to stereo vision (2): key matrix (essential matrix, basic matrix, homography matrix)
scipy.misc.imread()
嗨 FUN 一夏,与 StarRocks 一起玩转 SQL Planner!
OpenFeign
Causes and appropriate analysis of possible errors in seq2seq code of "hands on learning in depth"
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition
Configuration and startup of kubedm series-02-kubelet
[Niuke brush questions day4] jz55 depth of binary tree
Array, date, string object method
2311. Longest binary subsequence less than or equal to K
C#图像差异对比:图像相减(指针法、高速)
asp. Net (c)
Programming implementation of ROS learning 2 publisher node
[daiy4] jz32 print binary tree from top to bottom
Editor use of VI and VIM
生成对抗网络
Hi Fun Summer, play SQL planner with starrocks!
使用arm Neon操作,提高内存拷贝速度
Use and programming method of ros-8 parameters
location search 属性获取登录用户名




