1- /**
1+ /*
22 * Copyright 2016 Google Inc. All Rights Reserved.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16+
1617package com .example .appengine .appidentity ;
1718
1819import com .google .appengine .api .users .UserService ;
@@ -36,15 +37,16 @@ public UrlShortenerServlet() {
3637
3738 @ Override
3839 public void doGet (HttpServletRequest req , HttpServletResponse resp ) throws IOException {
39- PrintWriter w = resp .getWriter ();
40- w .println ("<!DOCTYPE html>" );
41- w .println ("<meta charset=\" utf-8\" >" );
42- w .println ("<title>Asserting Identity to Google APIs - App Engine App Identity Example</title>" );
43- w .println ("<form method=\" post\" >" );
44- w .println ("<label for=\" longUrl\" >URL:</label>" );
45- w .println ("<input id=\" longUrl\" name=\" longUrl\" type=\" text\" >" );
46- w .println ("<input type=\" submit\" value=\" Shorten\" >" );
47- w .println ("</form>" );
40+ PrintWriter writer = resp .getWriter ();
41+ writer .println ("<!DOCTYPE html>" );
42+ writer .println ("<meta charset=\" utf-8\" >" );
43+ writer .println (
44+ "<title>Asserting Identity to Google APIs - App Engine App Identity Example</title>" );
45+ writer .println ("<form method=\" post\" >" );
46+ writer .println ("<label for=\" longUrl\" >URL:</label>" );
47+ writer .println ("<input id=\" longUrl\" name=\" longUrl\" type=\" text\" >" );
48+ writer .println ("<input type=\" submit\" value=\" Shorten\" >" );
49+ writer .println ("</form>" );
4850 }
4951
5052 @ Override
@@ -57,19 +59,19 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOEx
5759 }
5860
5961 String shortUrl ;
60- PrintWriter w = resp .getWriter ();
62+ PrintWriter writer = resp .getWriter ();
6163 try {
6264 shortUrl = shortener .createShortUrl (longUrl );
6365 } catch (Exception e ) {
6466 resp .setStatus (HttpServletResponse .SC_INTERNAL_SERVER_ERROR );
65- w .println ("error shortening URL: " + longUrl );
67+ writer .println ("error shortening URL: " + longUrl );
6668 e .printStackTrace (w );
6769 return ;
6870 }
6971
70- w .print ("long URL: " );
71- w .println (longUrl );
72- w .print ("short URL: " );
73- w .println (shortUrl );
72+ writer .print ("long URL: " );
73+ writer .println (longUrl );
74+ writer .print ("short URL: " );
75+ writer .println (shortUrl );
7476 }
7577}
0 commit comments