ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/webapps/examples/WEB-INF/classes/async/Async2.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/webapps/examples/WEB-INF/classes/async/Async2.java
Status
scanned
Type
file
Name
Async2.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
Perl5 module source, ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
2588 (2.5 KB)
MD5
079b0f34c2f5b70da2efb67210dcf6bc
SHA1
f6a8a67c1ef674427cb564bdc186e9f19af3e183
SHA256
0d59c7eb6781430e4d74a37380c6fc9d8344eddb64f03169e7f25d37ec81c4ed
SHA512

      
    
SHA1_git
4d3270da40db54098ead9889cfd2a6d3e8c5385b
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
Async2.java | 2.5 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package async; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import jakarta.servlet.AsyncContext; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; public class Async2 extends HttpServlet { private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(Async2.class); @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { final AsyncContext actx = req.startAsync(); actx.setTimeout(30*1000); Runnable run = new Runnable() { @Override public void run() { try { Thread.currentThread().setName("Async2-Thread"); log.info("Putting AsyncThread to sleep"); Thread.sleep(2*1000); log.info("Writing data."); Date date = new Date(System.currentTimeMillis()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); actx.getResponse().getWriter().write( "Output from background thread. Time: " + sdf.format(date) + " "); actx.complete(); }catch (InterruptedException | IllegalStateException | IOException x) { log.error("Async2",x); } } }; Thread t = new Thread(run); t.start(); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
42.35
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9