public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; javax.servlet.jsp.PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html;charset=ISO-8859-1"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\n"); out.write("\n\n"); // Get the current user's ac WTAccountCredentials ac = WTAccountCredentials.current(); SecureInfoManagerImpl sim = new SecureInfoManagerImpl(); // Setup for permission checking boolean editInterfaces = false; if (sim.canEditEntity(ProtectedResourceConstants.PR_INTERFACES, ac)) editInterfaces = true; pageContext.setAttribute("editInterfaces", new Boolean(editInterfaces)); out.write(" \n"); String hostIP = null; try { hostIP = InetAddress.getLocalHost().getHostAddress(); // out.print(hostIP); } catch (UnknownHostException ex) { throw new Exception("Could not determine the local host address", ex); } out.write("\n\nvar javaScriptVar=\""); out.print(hostIP); out.write("\";\nvar javaScriptVar2=\""); out.print(editInterfaces); out.write("\";\n"); } catch (Throwable t) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (pageContext != null) pageContext.handlePageException(t); } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext); } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; _jspx_resourceInjector = (org.apache.jasper.runtime.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector"); out.write('\n'); out.write('\n'); out.write("\n<!DOCTYPE html>\n<html>\n<head>\n"); JspHelper.createTitle(out, request, request.getParameter("filename")); out.write("\n</head>\n<body onload=\"document.goto.dir.focus()\">\n"); Configuration conf = (Configuration) getServletContext().getAttribute(JspHelper.CURRENT_CONF); generateFileChunks(out, request, conf); out.write("\n<hr>\n"); generateFileDetails(out, request, conf); out.write("\n\n<h2>Local logs</h2>\n<a href=\"/logs/\">Log</a> directory\n\n"); out.println(ServletUtil.htmlFooter()); out.write('\n'); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
private void outputJson(HttpServletResponse response, Response<String> kv) throws IOException, JsonGenerationException, JsonMappingException { response.setContentType("application/json;charset=UTF-8"); response.setHeader("Pragma", "No-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires", 0); response.setContentType("application/json"); PrintWriter out = response.getWriter(); ObjectMapper om = JsonHelper.getObjectMapperInstance(); out.print(om.writeValueAsString(kv)); out.flush(); out.close(); }
/** * Permet de repondre a une requete web En affichant la liste des Spectacles et representations : * Utiliste JQuery javascript pour la mise en forme * * @param HttpServletRequest request requete * @param HttpServletResponse response reponse * @throw IOException, ServletException * @return void */ public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // Get the session object HttpSession session = req.getSession(true); // Get the output stream ServletOutputStream out = res.getOutputStream(); res.setContentType("text/html"); out.println("<HEAD><TITLE>Reservation de tickets </TITLE></HEAD><BODY>"); out.println("<h1> Reservations de tickets </h1>"); out.println("<BODY bgproperties=\"fixed\" background=\"/images/rideau.JPG\">"); out.println("<p align=\"Right\"><font face=\"Monotype Corsiva\"style=\"font-size: 16pt\">"); try { // Open the file that is the first // command line parameter String relativeWebPath = "/WEB-INF/files/JAVASCRIPTPROG.txt"; String absoluteDiskPath = this.getServletContext().getRealPath(relativeWebPath); File file = new File(absoluteDiskPath); FileInputStream fstream = new FileInputStream(file); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; // Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console out.println(strLine); } // Close the input stream in.close(); } catch (Exception e) { // Catch exception if any out.println("Error: " + e.getMessage()); } if (session.isNew() || session.getAttribute("session.PanierListe") == null) out.println("<a href=\"admin/admin.html\">Caddie (vide)</a></font><br></p>"); else if (session.getAttribute("session.PanierListe") != null) if (((PanierListe) session.getAttribute("session.PanierListe")).getSize() > 0) out.println( "<a href=\"admin/admin.html\">afficher caddie(" + ((PanierListe) session.getAttribute("session.PanierListe")).Liste.size() + "Representations dans le panier)" + "</a></font><br></p>"); try { Utilisateur user = Utilitaires.Identification(this); out.println(Utilitaires.AffichageAchat(user)); } catch (Exception e) { out.println(e.getMessage()); } out.println("</BODY>"); out.close(); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String title = "Reading All Request Parameters"; out.println( ServletUtilities.headWithTitle(title) + "<BODY BGCOLOR=\"#FDF5E6\">\n" + "<H1 ALIGN=CENTER>" + title + "</H1>\n" + "<TABLE BORDER=1 ALIGN=CENTER>\n" + "<TR BGCOLOR=\"#FFAD00\">\n" + "<TH>Parameter Name<TH>Parameter Value(s)"); Enumeration paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); out.println("<TR><TD>" + paramName + "\n<TD>"); String[] paramValues = request.getParameterValues(paramName); if (paramValues.length == 1) { String paramValue = paramValues[0]; if (paramValue.length() == 0) out.print("<I>No Value</I>"); else out.print(paramValue); } else { out.println("<UL>"); for (int i = 0; i < paramValues.length; i++) { out.println("<LI>" + paramValues[i]); } out.println("</UL>"); } } out.println("</TABLE>\n</BODY></HTML>"); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String title = "Session Tracking Example"; HttpSession session = request.getSession(true); String heading; Integer accessCount = (Integer) session.getAttribute("accessCount"); if (accessCount == null) { accessCount = new Integer(0); heading = "Welcome, Newcomer"; } else { heading = "Welcome Back"; accessCount = new Integer(accessCount.intValue() + 1); } session.setAttribute("accessCount", accessCount); out.println( "<BODY BGCOLOR=\"#FDF5E6\">\n" + "<H1 ALIGN=\"CENTER\">" + heading + "</H1>\n" + "<H2>Information on Your Session:</H2>\n" + "<TABLE BORDER=1 ALIGN=\"CENTER\">\n" + "<TR BGCOLOR=\"#FFAD00\">\n" + " <TH>Info Type<TH>Value\n" + "<TR>\n" + " <TD>ID\n" + " <TD>" + session.getId() + "\n" + "<TR>\n" + " <TD>Creation Time\n" + " <TD>" + new Date(session.getCreationTime()) + "\n" + "<TR>\n" + " <TD>Time of Last Access\n" + " <TD>" + new Date(session.getLastAccessedTime()) + "\n" + "<TR>\n" + " <TD>Number of Previous Accesses\n" + " <TD>" + accessCount + "\n" + "</TR>" + "</TABLE>\n"); // the following two statements show how to retrieve parameters in // the request. The URL format is something like: // http://localhost:8080/project2/servlet/ShowSession?myname=Chen%20Li String myname = request.getParameter("myname"); if (myname != null) out.println("Hey " + myname + "<br><br>"); out.println("</BODY></HTML>"); }
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); String support = "support"; // valid username HttpSession session = null; session = req.getSession(false); // Get user's session object (no new one) if (session == null) { invalidUser(out); // Intruder - reject return; } String userName = (String) session.getAttribute("user"); // get username if (!userName.equals(support)) { invalidUser(out); // Intruder - reject return; } String action = ""; if (req.getParameter("todo") != null) action = req.getParameter("todo"); if (action.equals("update")) { doUpdate(out); return; } out.println("<p>Nothing to do.</p>todo=" + action); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setContentType("text/xml;charset=gbk"); String cmd = JUtil.convertNull(request.getParameter("cmd")); String xml = null; try { if (cmd.equals("calExterContractApplyType")) { // 根据公司ID,获得对外合同申请的合同类别 xml = this.calExterContractApplyType(request, response); } else if (cmd.equals("calDefaultExterContractApprover")) { // 获得对外合同申请的默认审批人 xml = this.calDefaultExterContractApprover(request, response); } else if (cmd.equals("calDefaultGnOrgApprover")) { // 获得国内合作渠道申请的默认审批人 xml = this.calDefaultGnOrgApprover(request, response); } else if (cmd.equals("calNeedInputMoney")) { xml = this.calNeedInputMoney(request, response); } else if (cmd.equals("checkRepeatGnOrg")) { // 检查国内合作渠道的名称是否有重复 xml = this.checkRepeatGnOrg(request, response); } else { xml = ""; } } catch (Throwable e) { e.printStackTrace(); } java.io.PrintWriter out = response.getWriter(); out.write(xml); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); if (request.getParameter("setcookie") != null) { Cookie cookie = new Cookie("Learningjava", "Cookies!"); cookie.setMaxAge(3600); response.addCookie(cookie); out.println("<html><body><h1>Cookie Set...</h1>"); } else { out.println("<html><body>"); Cookie[] cookies = request.getCookies(); if (cookies.length == 0) { out.println("<h1>No cookies found...</h1>"); } else { for (int i = 0; i < cookies.length; i++) out.print( "<h1>Name: " + cookies[i].getName() + "<br>" + "Value: " + cookies[i].getValue() + "</h1>"); } out.println( "<p><a href=\"" + request.getRequestURI() + "?setcookie=true\">" + "Reset the Learning Java cookie.</a>"); } out.println("</body></html>"); }
void sendHTML( HttpServletRequest request, HttpServletResponse response, String script, Exception scriptError, Object scriptResult, StringBuffer scriptOutput, boolean capture) throws IOException { // Format the output using a simple templating utility SimpleTemplate st = new SimpleTemplate(BshServlet.class.getResource("page.template")); st.replace("version", getBshVersion()); // String requestURI = HttpUtils.getRequestURL( request ).toString() // I was told this should work String requestURI = request.getRequestURI(); st.replace("servletURL", requestURI); if (script != null) st.replace("script", script); else st.replace("script", exampleScript); if (capture) st.replace("captureOutErr", "CHECKED"); else st.replace("captureOutErr", ""); if (script != null) st.replace( "scriptResult", formatScriptResultHTML(script, scriptResult, scriptError, scriptOutput)); response.setContentType("text/html"); PrintWriter out = response.getWriter(); st.write(out); out.flush(); }
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); try { userObj = new User(); tmsManager = new TMSManager(); RequestDispatcher rd1 = request.getRequestDispatcher("./header"); rd1.include(request, response); out.println("<html><head><title>UpdateUser</title></head>"); out.println("<body onload=onSubmit() bgcolor =\"#ffcc00\">"); out.println("<form method =\"POST\" action =\"./updateUser\" ><br><br><br>"); out.println("<table border = 1 width = \"40%\" align = \"center\" bgcolor = \"#bbccff\">"); out.println("<caption><b>UpdateUser</b></caption>"); out.println("<tr><td style = font face: verdana>Enter User ID</td>"); out.println("<td><input type = \"text\" name = \"user_id\" ></td></tr>"); out.println( "<tr><td colspan = 2 align = \"center\"><input type = \"submit\" name = \"Submit\" value = \"Submit\">"); out.println("<input type = \"Reset\" name = \"Reset\" value = \"Clear\"></td></tr>"); out.println("</table>"); out.println("</body></html>"); // String user_id = request.getParameter("user_id"); // userObj = tmsManager.getUser(user_id); } catch (Exception e) { System.out.println(e.getMessage()); } RequestDispatcher rd2 = request.getRequestDispatcher("./footer"); rd2.include(request, response); }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { response.setContentType("text/html"); PrintWriter out = response.getWriter(); /*String n=request.getParameter("username"); out.print("Welcome "+n);*/ String name = request.getParameter("name"); String dob = request.getParameter("dob"); String address = request.getParameter("address"); String email = request.getParameter("email"); HttpSession session = request.getSession(true); String userid = (String) session.getAttribute("theName"); int AccNo = 0; String AccMsg = ""; DbCommunication db_comm = new DbCommunication(); AccNo = db_comm.accountCreation(name, dob, address, email, userid); // db_comm.accountCreation(name,email); AccMsg = "Account created successfully. Account number is:" + AccNo; // out.println(AccMsg); String redirectURL = "accountCreationPage.jsp"; response.sendRedirect(redirectURL); session.setAttribute("AccCreationalMsgStatus", "set"); session.setAttribute("AccCreationalMsg", AccMsg); } catch (Exception e) { System.out.println(e); } }
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException { try { ConnectionPool conPool = getConnectionPool(); if (!realAuthentication(request, conPool)) { String queryString = request.getQueryString(); if (request.getQueryString() == null) { queryString = ""; } // if user is not authenticated send to signin response.sendRedirect( response.encodeRedirectURL(URLAUTHSIGNIN + "?" + URLBUY + "?" + queryString)); } else { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Expires", "0"); response.setHeader("Pragma", "no-cache"); response.setContentType("text/html"); String errorMessage = processRequest(request, response, conPool); if (errorMessage != null) { request.setAttribute(StringInterface.ERRORPAGEATTR, errorMessage); RequestDispatcher rd = getServletContext().getRequestDispatcher(PATHUSERERROR); rd.include(request, response); } } } catch (Exception e) { throw new ServletException(e); } }
/** * Attempts to send an internal server error HTTP error, if possible. Otherwise simply pushes the * exception message to the output stream. * * @param message Message to be printed to the logger and to the output stream. * @param t Exception that caused the error. */ protected void filterError(String message, Throwable t) { log.error("XSLT filter error: " + message, t); if (false == origResponse.isCommitted()) { // Reset the buffer and previous status code. origResponse.reset(); origResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); origResponse.setContentType("text/html; charset=UTF-8"); } // Response committed. Just push the error to the output stream. try { final OutputStream os = origResponse.getOutputStream(); final PrintWriter osw = new PrintWriter(new OutputStreamWriter(os, "iso8859-1")); osw.write("<html><body><!-- " + XSLTFilterConstants.ERROR_TOKEN + " -->"); osw.write("<h1 style=\"color: red; margin-top: 1em;\">"); osw.write("Internal server exception"); osw.write("</h1>"); osw.write("<b>URI</b>: " + origRequest.getRequestURI() + "\n<br/><br/>"); serializeException(osw, t); if (t instanceof ServletException && ((ServletException) t).getRootCause() != null) { osw.write("<br/><br/><h2>ServletException root cause:</h2>"); serializeException(osw, ((ServletException) t).getRootCause()); } osw.write("</body></html>"); osw.flush(); } catch (IOException e) { // Not much to do in such case (connection broken most likely). log.debug("Filter error could not be returned to client."); } }
public void doGet(HttpServletRequest solicitacao, HttpServletResponse resposta) throws IOException, ServletException { resposta.setContentType("text/html"); PrintWriter out = resposta.getWriter(); out.println("<html>"); out.println("<body>"); out.println("<center>"); out.println("<h1>Insira os dados para a criação do cookie</h1>"); out.println("</center>"); out.println("<table border='0' width='400'>"); out.println("<tr>"); out.println("<td>"); out.println("<form method='post' action='ExemploCookies'>"); out.println("<font face='verdana' size='2'>"); out.println("Nome do cookie: < / font > "); out.println("<input type='text' name='nome' size = '20'>"); out.println("<br>"); out.println("<font face='verdana' size='2'>"); out.println("Valor do cookie: < / font > "); out.println("<input type='text' name='valor' size ='20'><br > "); out.println("</td>"); out.println("</tr>"); out.println("<tr>"); out.println("<td align='center'>"); out.println("<input type='submit' value='Criar' name = 'S1'>"); out.println(" "); out.println("<input type='reset' value='Limpar' name = 'S2'>"); out.println("</td>"); out.println("</tr>"); out.println("</table>"); out.println("</body>"); out.println("</html>"); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String title = "Showing Request Headers"; StringBuilder sb = new StringBuilder(); sb.append("<html>\n<head>\n"); sb.append("<title>" + title + "</title>\n"); sb.append("</head>\n"); sb.append("<body bgcolor='#FDF5E6'>\n"); sb.append("<h1 align='center'>" + title + "</h1>\n"); sb.append("<b> Request Method: </b>" + request.getMethod() + "<br>\n"); sb.append("<b> Request URI: </b>" + request.getRequestURI() + "<br>\n"); sb.append("<b> Request Protocol: </b>" + request.getProtocol() + "<br>\n"); sb.append("<table border=1 align='center'>\n"); sb.append("<tr bgcolor='#FFAD00'>\n"); sb.append("<th> Header Name </th><th> Header Value </th></tr>\n"); Enumeration headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = (String) headerNames.nextElement(); sb.append("<tr><td>" + headerName + "</td>"); sb.append("<td>" + request.getHeader(headerName) + "</td></tr>\n"); } sb.append("</table>\n"); sb.append("</body></html>"); out.println(sb.toString()); out.close(); }
public void doGet(HttpServletRequest rq, HttpServletResponse rs) { PrintWriter pw = null; try { pw = rs.getWriter(); rs.setContentType("application/json"); LoyaltyApplication loyaltyApplication = new LoyaltyApplication(); loyaltyApplication.removeOperator(Integer.parseInt(rq.getParameter("code"))); pw.println("{"); pw.println("\"success\":true,"); pw.println("\"message\":\"removed\""); pw.println("}"); } catch (ApplicationException ae) { System.out.println(ae); pw.println("{"); pw.println("\"success\":false,"); pw.println("\"errorMessage\":" + "\"" + ae + "\""); pw.println("}"); } catch (IOException ioe) { System.out.println(ioe); } }
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); Enumeration values = req.getParameterNames(); String name = ""; String value = ""; String id = ""; while (values.hasMoreElements()) { name = ((String) values.nextElement()).trim(); value = req.getParameter(name).trim(); if (name.equals("id")) id = value; } if (url.equals("")) { url = getServletContext().getInitParameter("url"); cas_url = getServletContext().getInitParameter("cas_url"); } HttpSession session = null; session = req.getSession(false); if (session != null) { session.invalidate(); } res.sendRedirect(cas_url); return; }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html; charset=UTF-8"); Tools.sendDisableCacheHeaders(response); final PrintWriter out = response.getWriter(); out.println("<html>"); out.println(" <body>"); Cookie cookie = getCookie("carlos-cookie-test", request); if (cookie == null) { print(out, "No cookie set."); } else { print(out, "<b>Cookie ID</b>: " + cookie.getName() + "<br>"); print(out, "<b>Value</b>: " + cookie.getValue() + "<br>"); refreshCookie(cookie, response); } out.println(" <br>"); out.println(" <form method=\"post\">"); out.println(" <input type=\"submit\" value=\"create\" name=\"button\"><br><br>"); out.println(" <input type=\"submit\" value=\"delete\" name=\"button\"><br><br>"); out.println(" <input type=\"submit\" value=\"no-pass\" name=\"button\"><br>"); out.println(" </form>"); out.println(" </body>"); out.println("</html>"); out.close(); }
private void setContentType(HttpServletResponse pResp, String pContentType) { boolean encodingDone = false; try { pResp.setCharacterEncoding("utf-8"); pResp.setContentType(pContentType); encodingDone = true; } catch (NoSuchMethodError error) { /* Servlet 2.3 */ } catch (UnsupportedOperationException error) { /* Equinox HTTP Service */ } if (!encodingDone) { // For a Servlet 2.3 container or an Equinox HTTP Service, set the charset by hand pResp.setContentType(pContentType + "; charset=utf-8"); } }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // POST method only used for tracked login operation HttpSession session = request.getSession(); response.setContentType("text/plain"); PrintWriter out = response.getWriter(); // Get the username and password from request String username = request.getParameter("id"); String password = request.getParameter("pwd"); Long id = 0L; try { id = Long.parseLong(username); } catch (Exception ex) { } if (username != null && password != null) { // Login into tracked system CTracked ctracked = db.loginTrackedFromMobile(id, password).getResult(); if (ctracked != null) { // Login successful out.print("OK," + ctracked.getUsername()); session.setAttribute("device_id", ctracked.getUsername()); log.info(ctracked + " : logined!"); } } }
public void doGet(HttpServletRequest rq, HttpServletResponse rs) { PrintWriter pw = null; try { pw = rs.getWriter(); rs.setContentType("application/json"); OperatorBLInterface operatorInterface = new Operator(); LoyaltyApplication loyaltyApplication = new LoyaltyApplication(); boolean found = loyaltyApplication.operatorExists(Integer.parseInt(rq.getParameter("code"))); pw.println("{"); pw.println("\"success\":true,"); pw.println("\"found\":" + found); pw.println("}"); } catch (ApplicationException ae) { System.out.println(ae); pw.println("{"); pw.println("\"success\":false,"); pw.println("\"errorMessage\":" + "\"" + ae + "\""); pw.println("}"); } catch (Exception e) { System.out.println(e); } }
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/html"); try { PrintWriter pw = res.getWriter(); pw.println("<html><head><TITLE>Web-Enabled Automated Manufacturing System</TITLE></head>"); pw.println( "<body><br><br><br><form name=modifyuser method=post action='http://peers:8080/servlet/showUser')"); v = U.allUsers(); pw.println("<table align='center' border=0> <tr><td>"); pw.println( "Select User Name To Modify</td><td><SELECT id=select1 name=uid style='HEIGHT: 22px; LEFT: 74px; TOP: 222px; WIDTH: 155px'>"); pw.println("<OPTION selected value=''></OPTION>"); for (i = 0; i < v.size(); i++) pw.println( "<OPTION value=" + (String) v.elementAt(i) + ">" + (String) v.elementAt(i) + "</OPTION>"); pw.println( "</SELECT></td></tr><tr><td></td><td><input type='submit' name='submit' value='Submit'></td></tr></table></form></body></html>"); pw.flush(); pw.close(); } catch (Exception e) { } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write('\n'); out.write('\n'); out.write("\n\n\n\n<html>\n<head>\n"); JspHelper.createTitle(out, request, request.getParameter("filename")); out.write("\n</head>\n<body>\n<form action=\"/tail.jsp\" method=\"GET\">\n"); generateFileChunks(out, request); out.write("\n</form>\n<hr>\n\n<h2>Local logs</h2>\n<a href=\"/logs/\">Log</a> directory\n\n"); out.println(ServletUtil.htmlFooter()); out.write('\n'); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } }
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String username = request.getParameter("username"); String password = request.getParameter("password"); Statement stmt; ResultSet rs; Connection con = null; try { Class.forName("com.mysql.jdbc.Driver"); String connectionUrl = "jdbc:mysql://localhost/myflickr?" + "user=root&password=123456"; con = DriverManager.getConnection(connectionUrl); if (con != null) { System.out.println("connected to mysql"); } } catch (SQLException e) { System.out.println("SQL Exception: " + e.toString()); } catch (ClassNotFoundException cE) { System.out.println("Class Not Found Exception: " + cE.toString()); } try { stmt = con.createStatement(); System.out.println("SELECT * FROM flickrusers WHERE name='" + username + "'"); rs = stmt.executeQuery("SELECT * FROM flickrusers WHERE name='" + username + "'"); while (rs.next()) { if (rs.getObject(1).toString().equals(username)) { out.println("<h1>To username pou epileksate uparxei hdh</h1>"); out.println("<a href=\"project3.html\">parakalw dokimaste kapoio allo.</a>"); stmt.close(); rs.close(); return; } } stmt.close(); rs.close(); stmt = con.createStatement(); if (!stmt.execute("INSERT INTO flickrusers VALUES('" + username + "', '" + password + "')")) { out.println("<h1>Your registration is completed " + username + "</h1>"); out.println("<a href=\"index.jsp\">go to the login menu</a>"); registerListener.Register(username); } else { out.println("<h1>To username pou epileksate uparxei hdh</h1>"); out.println("<a href=\"project3.html\">Register</a>"); } } catch (SQLException e) { throw new ServletException("Servlet Could not display records.", e); } }
/** Initializes the output. Sets the expected encoding and content type. */ public void initResponse() { // set content type and encoding final SerializerOptions opts = sopts(); final String enc = opts.get(SerializerOptions.ENCODING); res.setCharacterEncoding(enc); final String ct = mediaType(opts); res.setContentType(new TokenBuilder(ct).add(CHARSET).add(enc).toString()); }
/** {@inheritDoc} */ @Override public void handle(String target, Request req, HttpServletRequest srvReq, HttpServletResponse res) throws IOException, ServletException { if (log.isDebugEnabled()) log.debug("Handling request [target=" + target + ", req=" + req + ", srvReq=" + srvReq + ']'); if (target.startsWith("/gridgain")) { processRequest(target, srvReq, res); req.setHandled(true); } else if (target.startsWith("/favicon.ico")) { if (favicon == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); req.setHandled(true); return; } res.setStatus(HttpServletResponse.SC_OK); res.setContentType("image/x-icon"); res.getOutputStream().write(favicon); res.getOutputStream().flush(); req.setHandled(true); } else { if (dfltPage == null) { res.setStatus(HttpServletResponse.SC_NOT_FOUND); req.setHandled(true); return; } res.setStatus(HttpServletResponse.SC_OK); res.setContentType("text/html"); res.getWriter().write(dfltPage); res.getWriter().flush(); req.setHandled(true); } }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); System.out.println("queryString: " + request.getQueryString()); out.println("FILTER-QUERYSTRING:" + (request.getQueryString() != null ? "PASS" : "FAIL")); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter pw = response.getWriter(); HttpSession session = request.getSession(); String str = (String) session.getAttribute("foo"); pw.println("The name is " + str); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // Prepare this response response.setContentType("text/plain"); PrintWriter writer = response.getWriter(); writer.println("ResponseWrap01c PASSED"); }