1
1
/**
2
2
* Copyright 2015 Google Inc. All Rights Reserved.
3
- *
3
+ * <p>
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
6
6
* You may obtain a copy of the License at
7
- *
7
+ * <p>
8
8
* http://www.apache.org/licenses/LICENSE-2.0
9
- *
9
+ * <p>
10
10
* Unless required by applicable law or agreed to in writing, software
11
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
16
17
17
package com .example .appengine ;
18
18
19
- import javax .servlet .ServletException ;
20
- import javax .servlet .http .HttpServlet ;
21
- import javax .servlet .http .HttpServletRequest ;
22
- import javax .servlet .http .HttpServletResponse ;
19
+ import org .json .JSONObject ;
20
+
23
21
import java .io .BufferedReader ;
24
22
import java .io .IOException ;
25
23
import java .io .InputStreamReader ;
26
24
import java .io .OutputStreamWriter ;
27
25
import java .net .HttpURLConnection ;
28
26
import java .net .URL ;
29
27
import java .net .URLEncoder ;
30
-
31
- import org .json .JSONObject ;
28
+ import javax .servlet .ServletException ;
29
+ import javax .servlet .http .HttpServlet ;
30
+ import javax .servlet .http .HttpServletRequest ;
31
+ import javax .servlet .http .HttpServletResponse ;
32
32
33
33
@ SuppressWarnings ("serial" )
34
34
public class UrlFetchServlet extends HttpServlet {
@@ -63,7 +63,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp)
63
63
64
64
if (id == null || text == null || id == "" || text == "" ) {
65
65
req .setAttribute ("error" , "invalid input" );
66
- req .getRequestDispatcher ("/main.jsp" ).forward (req ,resp );
66
+ req .getRequestDispatcher ("/main.jsp" ).forward (req , resp );
67
67
return ;
68
68
}
69
69
@@ -85,7 +85,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp)
85
85
86
86
int respCode = conn .getResponseCode (); // New items get NOT_FOUND on PUT
87
87
if (respCode == HttpURLConnection .HTTP_OK || respCode == HttpURLConnection .HTTP_NOT_FOUND ) {
88
- req .setAttribute ("error" , "" );
88
+ req .setAttribute ("error" , "" );
89
89
StringBuffer response = new StringBuffer ();
90
90
String line ;
91
91
@@ -98,7 +98,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp)
98
98
} else {
99
99
req .setAttribute ("error" , conn .getResponseCode () + " " + conn .getResponseMessage ());
100
100
}
101
- // [END complex]
101
+ // [END complex]
102
102
req .getRequestDispatcher ("/main.jsp" ).forward (req , resp );
103
103
}
104
104
0 commit comments