Quantcast
Channel: JetBrains Developer Community : Thread List - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5661

Idea get into infinite sending request to my web app when web app start up

$
0
0

Idea version : 14.1

tomcat version: 7.0.47

java version: 1.7.0_51

OS: OS X 10.10.2

Default browser: chrome 41.0.2272.104 (64-bit)

 

I set up a simple web app sample of java servlet. But it get into infinite loop when I use the idea option "Run/Debug Configurations - Open browser - After launch".

 

My Code:

 

LogFilter.java

 

publicclass LogFilter implements Filter {     @Override    publicvoid init(FilterConfig filterConfig) throws ServletException {     }     @Override    publicvoid doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {        System.out.println("Test");        chain.doFilter(request, response);    }     @Override    publicvoid destroy() {     }} 

 

SimpleServlet.java

 

publicclass SimpleServlet extends HttpServlet {     privatefinalstatic String USERNAME = "test";    privatefinalstatic String PASSWORD = "root";     @Override    protectedvoid doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {        String user = req.getParameter("username");        String pass = req.getParameter("password");         resp.setHeader(HttpHeaders.CONTENT_TYPE, "text/html; charset=UTF-8");        if (user != null&& user.equals(USERNAME) && pass != null&& pass.equals(PASSWORD)) {            resp.getWriter().write("succ");        }else{            resp.getWriter().write("fail");        }    }}   

 

web.xml

 

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE web-app        PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN        http://java.sun.com/dtd/web-app_2_3.dtd><web-app>    <filter>        <filter-name>logFilter</filter-name>        <filter-class>com.qunar.fresh.zhenweiliu.servlet.LogFilter</filter-class>    </filter>    <filter-mapping>        <filter-name>logFilter</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>    <servlet>        <servlet-name>controlServlet</servlet-name>        <servlet-class>com.qunar.fresh.zhenweiliu.servlet.SimpleServlet</servlet-class>        <!--<load-on-startup>1</load-on-startup>-->    </servlet>    <servlet-mapping>        <servlet-name>controlServlet</servlet-name>        <!--<url-pattern>/*</url-pattern>-->        <url-pattern>/login</url-pattern>    </servlet-mapping></web-app>

 

 

The thing is, when I click the debug button, the artifact deploy successfully.But the browser window never pop up, and the console keep infinite print "Test Test Test ...",

which means the filter is invoked infinitely.

 

If I uncheck the After Launch option in Run/Debug Configurations. Problem disappeard.

 

So I think there is something makes idea can not open the brower. And idea keep openning the browser, and keep sending a request "localhost:8080" and triger the Filter infinitely.

 

Is there something wrong with my code ? Or a bug of idea ?

 

Update :

 

I use tcpdump to grep some packet.

 

sudo tcpdump -X -i lo0 dst host localhost and dst port 8080

 

It shows there many packets like below:

 

22:45:50.208234 IP localhost.60174 > localhost.http-alt: Flags [P.], seq 0:219, ack 1, win 12759, options [nop,nop,TS val 452236887 ecr 452236887], length 219     0x0000:  4500 010f 0491 4000 4006 0000 7f00 0001  E.....@.@.......     0x0010:  7f00 0001 eb0e 1f90 a3ae 7690 cd4f 06b3  ..........v..O..     0x0020:  8018 31d7 ff03 0000 0101 080a 1af4 9657  ..1............W     0x0030:  1af4 9657 4745 5420 2f20 4854 5450 2f31  ...WGET./.HTTP/1     0x0040:  2e31 0d0a 5573 6572 2d41 6765 6e74 3a20  .1..User-Agent:.     0x0050:  496e 7465 6c6c 694a 2049 4445 410d 0a41  IntelliJ.IDEA..A     0x0060:  6363 6570 742d 456e 636f 6469 6e67 3a20  ccept-Encoding:.     0x0070:  677a 6970 0d0a 4361 6368 652d 436f 6e74  gzip..Cache-Cont     0x0080:  726f 6c3a 206e 6f2d 6361 6368 650d 0a50  rol:.no-cache..P     0x0090:  7261 676d 613a 206e 6f2d 6361 6368 650d  ragma:.no-cache.     0x00a0:  0a48 6f73 743a 206c 6f63 616c 686f 7374  .Host:.localhost     0x00b0:  3a38 3038 300d 0a41 6363 6570 743a 2074  :8080..Accept:.t     0x00c0:  6578 742f 6874 6d6c 2c20 696d 6167 652f  ext/html,.image/     0x00d0:  6769 662c 2069 6d61 6765 2f6a 7065 672c  gif,.image/jpeg,     0x00e0:  202a 3b20 713d 2e32 2c20 2a2f 2a3b 2071  .*;.q=.2,.*/*;.q     0x00f0:  3d2e 320d 0a43 6f6e 6e65 6374 696f 6e3a  =.2..Connection:     0x0100:  206b 6565 702d 616c 6976 650d 0a0d 0a    .keep-alive....

Viewing all articles
Browse latest Browse all 5661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>