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) { } }
/** * Is used to remember the order of variables so that the message returned to the OA does not * contain randomly ordered data. * * @param message The RuleML message * @return An array containing the order of the variables. */ public static String[] getVariableOrder(String message) { Vector<String> variables = new Vector<String>(); String[] variableList; // Break string up StringTokenizer st = new StringTokenizer(message, "<"); String temp = ""; // Temporary storage String tempVar = ""; // Temporary variable storage // While information remains while (st.hasMoreTokens()) { temp = st.nextToken(); // If it is a variable if (temp.startsWith("Var>")) { tempVar = ""; // Get the name of the variable for (int i = 4; i < temp.length(); i++) { if (temp.charAt(i) == '<') break; else tempVar = tempVar + temp.charAt(i); } variables.addElement(tempVar); // Store the variable name } } // Convert the vector to an array variableList = new String[variables.size()]; for (int i = 0; i < variables.size(); i++) { variableList[i] = variables.elementAt(i); } return variableList; }
/** * Returns the value of the named parameter as a String, or null if the parameter was not sent or * was sent without a value. The value is guaranteed to be in its normal, decoded form. If the * parameter has multiple values, only the last one is returned (for backward compatibility). For * parameters with multiple values, it's possible the last "value" may be null. * * @param name the parameter name. * @return the parameter value. */ public String getParameter(String name) { try { Vector values = (Vector) parameters.get(name); if (values == null || values.size() == 0) { return null; } String value = (String) values.elementAt(values.size() - 1); return value; } catch (Exception e) { return null; } }
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/html"); hs = req.getSession(true); PrintWriter pw = res.getWriter(); uid = req.getParameter("did"); if (!uid.equals("")) { v = D.getDealer(uid); pw.println( "<html><head><TITLE>Web-Enabled Automated Manufacturing System</TITLE><script language=javascript>function set() {"); pw.println( "document.deldealer.select1.value='" + (String) v.elementAt(4) + "'} </script></head><P align=center><FONT color=deepskyblue size=4><STRONG>MODIFY DEALER </STRONG></FONT></P> "); pw.println( "<body onLoad=set()><br><br><form name=deldealer method=post action='http://peers:8080/servlet/DelDealer'>"); pw.println( "<center><TABLE border=0 cellPadding=1 cellSpacing=1 width='75%' style='HEIGHT: 147px; WIDTH: 248px'>"); pw.println( "<TR><TD>DealerId </TD><TD><INPUT id=text1 name=did value=" + (String) v.elementAt(0) + "></TD></TR>"); pw.println( "<TR><TD>DealerName</TD><TD><INPUT id=text2 name=dname value=" + (String) v.elementAt(1) + " ></TD></TR><TR><TD>DealerAddress</TD>"); pw.println( "<TD><INPUT id=text2 type=text name=daddr value=" + (String) v.elementAt(2) + "></TD></TR><TR><TD>CreditLimit</TD><TD><INPUT id=text4 name=cl value=" + v.get(3).toString()); pw.println( "></TD></TR><TR><TD><P>Staus</P></TD><td><SELECT id=select1 name=status style='HEIGHT: 22px; LEFT: 1px; TOP: 1px; WIDTH: 136px'> <OPTION "); pw.println( "selected value=''></OPTION><OPTION value=Active>Active</OPTION><OPTION value=Inactive>Inactive</OPTION></SELECT><INPUT id=submit1 name=submit1 style='LEFT: 151px; TOP: 318px' type=submit value=Delete></TD></TR>"); pw.println("</table></center></form></body></html>"); pw.flush(); pw.close(); } }
private void _jspService( javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.caucho.jsp.PageContextImpl pageContext, javax.servlet.ServletContext application, javax.servlet.http.HttpSession session, TagState _jsp_state) throws Throwable { javax.servlet.jsp.JspWriter out = pageContext.getOut(); final javax.el.ELContext _jsp_env = pageContext.getELContext(); javax.servlet.ServletConfig config = getServletConfig(); javax.servlet.Servlet page = this; javax.servlet.jsp.tagext.JspTag _jsp_parent_tag = null; com.caucho.jsp.PageContextImpl _jsp_parentContext = pageContext; response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); out.write(_jsp_string0, 0, _jsp_string0.length); CP_Classes.EthnicGroup ethnic; synchronized (pageContext.getSession()) { ethnic = (CP_Classes.EthnicGroup) pageContext.getSession().getAttribute("ethnic"); if (ethnic == null) { ethnic = new CP_Classes.EthnicGroup(); pageContext.getSession().setAttribute("ethnic", ethnic); } } out.write(_jsp_string1, 0, _jsp_string1.length); CP_Classes.Login logchk; synchronized (pageContext.getSession()) { logchk = (CP_Classes.Login) pageContext.getSession().getAttribute("logchk"); if (logchk == null) { logchk = new CP_Classes.Login(); pageContext.getSession().setAttribute("logchk", logchk); } } out.write(_jsp_string1, 0, _jsp_string1.length); CP_Classes.Translate trans; synchronized (pageContext.getSession()) { trans = (CP_Classes.Translate) pageContext.getSession().getAttribute("trans"); if (trans == null) { trans = new CP_Classes.Translate(); pageContext.getSession().setAttribute("trans", trans); } } out.write(_jsp_string1, 0, _jsp_string1.length); // added to check whether organisation is a consulting company // Mark Oei 09 Mar 2010 out.write(_jsp_string1, 0, _jsp_string1.length); CP_Classes.Organization Org; synchronized (pageContext.getSession()) { Org = (CP_Classes.Organization) pageContext.getSession().getAttribute("Org"); if (Org == null) { Org = new CP_Classes.Organization(); pageContext.getSession().setAttribute("Org", Org); } } out.write(_jsp_string1, 0, _jsp_string1.length); CP_Classes.Create_Edit_Survey CE_Survey; synchronized (pageContext.getSession()) { CE_Survey = (CP_Classes.Create_Edit_Survey) pageContext.getSession().getAttribute("CE_Survey"); if (CE_Survey == null) { CE_Survey = new CP_Classes.Create_Edit_Survey(); pageContext.getSession().setAttribute("CE_Survey", CE_Survey); } } out.write(_jsp_string2, 0, _jsp_string2.length); // by lydia Date 05/09/2008 Fix jsp file to support Thai language out.write(_jsp_string3, 0, _jsp_string3.length); out.print((trans.tslt("Delete Ethnic Group"))); out.write(_jsp_string4, 0, _jsp_string4.length); out.print((trans.tslt("Edit Ethnic Group"))); out.write(_jsp_string5, 0, _jsp_string5.length); out.print((trans.tslt("Please enter Ethnic Group"))); out.write(_jsp_string6, 0, _jsp_string6.length); out.print((trans.tslt("Add Ethnic Group"))); out.write(_jsp_string7, 0, _jsp_string7.length); out.print((trans.tslt("Please enter Ethnic Group"))); out.write(_jsp_string8, 0, _jsp_string8.length); String username = (String) session.getAttribute("username"); if (!logchk.isUsable(username)) { out.write(_jsp_string9, 0, _jsp_string9.length); } else { if (request.getParameter("proceed") != null) { int PKOrg = new Integer(request.getParameter("proceed")).intValue(); logchk.setOrg(PKOrg); } if (request.getParameter("Delete") != null) { int Ethnic_ID = new Integer(request.getParameter("ethnic_ID")).intValue(); boolean bIsDeleted = ethnic.deleteRecord(Ethnic_ID, logchk.getPKUser()); if (bIsDeleted) { out.write(_jsp_string10, 0, _jsp_string10.length); } } if (request.getParameter("Edit") != null) { int Ethnic_ID = new Integer(request.getParameter("ethnic_ID")).intValue(); String txtEthnic = request.getParameter("txtEthnic"); boolean bIsEdited = ethnic.editRecord(Ethnic_ID, txtEthnic, logchk.getOrg(), logchk.getPKUser()); if (bIsEdited) { out.write(_jsp_string11, 0, _jsp_string11.length); } else { out.write(_jsp_string12, 0, _jsp_string12.length); } } if (request.getParameter("Add") != null) { String txtEthnic = request.getParameter("txtEthnic"); boolean bExist = ethnic.existRecord(txtEthnic, logchk.getOrg()); if (!bExist) { boolean bIsAdded = ethnic.addRecord(txtEthnic, logchk.getOrg(), logchk.getPKUser()); if (bIsAdded) { out.write(_jsp_string13, 0, _jsp_string13.length); } } else { out.write(_jsp_string14, 0, _jsp_string14.length); } } out.write(_jsp_string15, 0, _jsp_string15.length); out.print((trans.tslt("Ethnic Group"))); out.write(_jsp_string16, 0, _jsp_string16.length); out.print((trans.tslt("To Add, click on the Add button"))); out.write(_jsp_string17, 0, _jsp_string17.length); out.print( (trans.tslt("To Edit, click on the relevant radio button and click on the Edit button"))); out.write(_jsp_string17, 0, _jsp_string17.length); out.print( (trans.tslt( "To Delete, click on the relevant radio button and click on the Delete button"))); out.write(_jsp_string18, 0, _jsp_string18.length); out.print((trans.tslt("Organisation"))); out.write(_jsp_string19, 0, _jsp_string19.length); // Added to check whether organisation is also a consulting company // if yes, will display a dropdown list of organisation managed by this company // else, it will display the current organisation only // Mark Oei 09 Mar 2010 String[] UserDetail = new String[14]; UserDetail = CE_Survey.getUserDetail(logchk.getPKUser()); boolean isConsulting = true; isConsulting = Org.isConsulting(UserDetail[10]); // check whether organisation is a consulting company if (isConsulting) { Vector vOrg = logchk.getOrgList(logchk.getCompany()); for (int i = 0; i < vOrg.size(); i++) { votblOrganization vo = (votblOrganization) vOrg.elementAt(i); int PKOrg = vo.getPKOrganization(); String OrgName = vo.getOrganizationName(); if (logchk.getOrg() == PKOrg) { out.write(_jsp_string20, 0, _jsp_string20.length); out.print((PKOrg)); out.write(_jsp_string21, 0, _jsp_string21.length); out.print((OrgName)); out.write(_jsp_string22, 0, _jsp_string22.length); } else { out.write(_jsp_string20, 0, _jsp_string20.length); out.print((PKOrg)); out.write('>'); out.print((OrgName)); out.write(_jsp_string22, 0, _jsp_string22.length); } } } else { out.write(_jsp_string23, 0, _jsp_string23.length); out.print((logchk.getSelfOrg())); out.write('>'); out.print((UserDetail[10])); out.write(_jsp_string24, 0, _jsp_string24.length); } // End of isConsulting out.write(_jsp_string25, 0, _jsp_string25.length); out.print((trans.tslt("Ethnic Group"))); out.write(_jsp_string26, 0, _jsp_string26.length); /** ****************** Edited by James 17 Oct 2007 ********************** */ Vector v = ethnic.getAllEthnics(logchk.getOrg()); for (int i = 0; i < v.size(); i++) { voEthnic vo = (voEthnic) v.elementAt(i); int ethnic_ID = vo.getPKEthnic(); String ethnic_Desc = vo.getEthnicDesc(); out.write(_jsp_string27, 0, _jsp_string27.length); out.print((ethnic_ID)); out.write(_jsp_string28, 0, _jsp_string28.length); out.print((ethnic_Desc)); out.write(_jsp_string29, 0, _jsp_string29.length); out.print((ethnic_Desc)); out.write(_jsp_string30, 0, _jsp_string30.length); } out.write(_jsp_string31, 0, _jsp_string31.length); out.print((trans.tslt("Ethnic Group"))); out.write(_jsp_string32, 0, _jsp_string32.length); out.print((trans.tslt("Add"))); out.write(_jsp_string33, 0, _jsp_string33.length); out.print((trans.tslt("Edit"))); out.write(_jsp_string34, 0, _jsp_string34.length); out.print((trans.tslt("Delete"))); out.write(_jsp_string35, 0, _jsp_string35.length); } out.write(_jsp_string36, 0, _jsp_string36.length); // by lydia Date 05/09/2008 Fix jsp file to support Thai language out.write(_jsp_string37, 0, _jsp_string37.length); Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); out.write(_jsp_string38, 0, _jsp_string38.length); // Denise 05/01/2010 update new email address out.write(_jsp_string39, 0, _jsp_string39.length); out.print((year)); out.write(_jsp_string40, 0, _jsp_string40.length); }
private void _jspService( javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.caucho.jsp.PageContextImpl pageContext, javax.servlet.ServletContext application, javax.servlet.http.HttpSession session, TagState _jsp_state) throws Throwable { javax.servlet.jsp.JspWriter out = pageContext.getOut(); final javax.el.ELContext _jsp_env = pageContext.getELContext(); javax.servlet.ServletConfig config = getServletConfig(); javax.servlet.Servlet page = this; javax.servlet.jsp.tagext.JspTag _jsp_parent_tag = null; com.caucho.jsp.PageContextImpl _jsp_parentContext = pageContext; response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); out.write(_jsp_string0, 0, _jsp_string0.length); CP_Classes.Login logchk; synchronized (pageContext.getSession()) { logchk = (CP_Classes.Login) pageContext.getSession().getAttribute("logchk"); if (logchk == null) { logchk = new CP_Classes.Login(); pageContext.getSession().setAttribute("logchk", logchk); } } out.write(_jsp_string1, 0, _jsp_string1.length); CP_Classes.Create_Edit_Survey CE_Survey; synchronized (pageContext.getSession()) { CE_Survey = (CP_Classes.Create_Edit_Survey) pageContext.getSession().getAttribute("CE_Survey"); if (CE_Survey == null) { CE_Survey = new CP_Classes.Create_Edit_Survey(); pageContext.getSession().setAttribute("CE_Survey", CE_Survey); } } out.write(_jsp_string2, 0, _jsp_string2.length); CP_Classes.Translate trans; synchronized (pageContext.getSession()) { trans = (CP_Classes.Translate) pageContext.getSession().getAttribute("trans"); if (trans == null) { trans = new CP_Classes.Translate(); pageContext.getSession().setAttribute("trans", trans); } } out.write(_jsp_string2, 0, _jsp_string2.length); CP_Classes.RatingTask RT; synchronized (pageContext.getSession()) { RT = (CP_Classes.RatingTask) pageContext.getSession().getAttribute("RT"); if (RT == null) { RT = new CP_Classes.RatingTask(); pageContext.getSession().setAttribute("RT", RT); } } out.write(_jsp_string2, 0, _jsp_string2.length); CP_Classes.RatingScale RS; synchronized (pageContext.getSession()) { RS = (CP_Classes.RatingScale) pageContext.getSession().getAttribute("RS"); if (RS == null) { RS = new CP_Classes.RatingScale(); pageContext.getSession().setAttribute("RS", RS); } } out.write(_jsp_string2, 0, _jsp_string2.length); CP_Classes.Purpose PRP; synchronized (pageContext.getSession()) { PRP = (CP_Classes.Purpose) pageContext.getSession().getAttribute("PRP"); if (PRP == null) { PRP = new CP_Classes.Purpose(); pageContext.getSession().setAttribute("PRP", PRP); } } out.write(_jsp_string2, 0, _jsp_string2.length); CP_Classes.SurveyRating SVR; synchronized (pageContext.getSession()) { SVR = (CP_Classes.SurveyRating) pageContext.getSession().getAttribute("SVR"); if (SVR == null) { SVR = new CP_Classes.SurveyRating(); pageContext.getSession().setAttribute("SVR", SVR); } } out.write(_jsp_string3, 0, _jsp_string3.length); // by lydia Date 05/09/2008 Fix jsp file to support Thai language out.write(_jsp_string4, 0, _jsp_string4.length); out.print((trans.tslt("Please choose a rating task"))); out.write(_jsp_string5, 0, _jsp_string5.length); response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("expires", 0); String username = (String) session.getAttribute("username"); if (!logchk.isUsable(username)) { out.write(_jsp_string6, 0, _jsp_string6.length); } else { if (request.getParameter("purpose") != null) { int var1 = new Integer(request.getParameter("purpose")).intValue(); CE_Survey.setPurpose(var1); System.out.println("Purpose ID" + var1); } else { // Edited by Eric Lu 22/5/08 // Resets purpose if first time accessing this page CE_Survey.setPurpose(0); } if (request.getParameter("add") != null) { String rating = ""; String scale = ""; boolean RequiredChosen = false; String[] chkSelect = new String[10]; String[] ScaleDesc = new String[10]; String[] radioSelect = new String[10]; int SurveyID = CE_Survey.getSurvey_ID(); ScaleDesc = request.getParameterValues("selScaleDesc"); chkSelect = request.getParameterValues("chkRat"); radioSelect = request.getParameterValues("radioRat"); int count = 0; // count shifted, Mark Oei 16 April 2010 /*------------------------------------------------- for checkbox ------------------------------------------------*/ // Changed by Ha 28/05/09 to pop out message when action is done successfully if (chkSelect != null) { boolean added = false; count = 0; // change to declare variable outside if statement, Mark Oei 16 April 2010 for (int i = 0; i < chkSelect.length; i++) { rating = chkSelect[i]; if (rating != null) { String RatName = " "; RatName = RT.getRatingTask(Integer.parseInt(rating)); ScaleDesc = new String[10]; ScaleDesc = request.getParameterValues("selScaleDesc" + rating); for (int j = 0; j < ScaleDesc.length; j++) { scale = ScaleDesc[j]; CE_Survey.editPurpose(SurveyID, CE_Survey.getPurpose()); added = CE_Survey.addRating(SurveyID, scale, rating, RatName); if (added) count++; } } } // Added to insert default values into database when rating tasks are added // Mark Oei 16 April 2010 int lLimit = 0; int uLimit = 0; int scaleRange = CE_Survey.getRatScale(); int taskCount = (Integer) session.getAttribute("taskCount") + count; if ((taskCount == 1 && Integer.parseInt(rating) == 1)) { lLimit = scaleRange / 2 - 1; uLimit = scaleRange / 2 + 1; } else { lLimit = -1; uLimit = 1; } boolean isSuccessful = CE_Survey.setMinPassScore(SurveyID, lLimit, uLimit); if (isSuccessful) { System.out.println( "Default Limits " + lLimit + ", " + uLimit + " has been inserted successfully"); } if (count == chkSelect.length) { out.write(_jsp_string7, 0, _jsp_string7.length); } } /*-------------------------------------------------------- for radiobox ----------------------------------------------*/ rating = ""; if (radioSelect != null) { for (int i = 0; i < radioSelect.length; i++) { rating = radioSelect[i]; if (rating != null) { String RatName = RT.getRatingTask(Integer.parseInt(rating)); ScaleDesc = new String[10]; ScaleDesc = request.getParameterValues("selScaleDesc" + rating); for (int j = 0; j < ScaleDesc.length; j++) { scale = ScaleDesc[j]; CE_Survey.addRating(SurveyID, scale, rating, RatName); } } } } out.write(_jsp_string8, 0, _jsp_string8.length); } out.write(_jsp_string9, 0, _jsp_string9.length); out.print((trans.tslt("To Select Rating Task, checked on the provided boxes under Select"))); out.write(_jsp_string10, 0, _jsp_string10.length); out.print((trans.tslt("Purpose of Survey"))); out.write(_jsp_string11, 0, _jsp_string11.length); out.print((trans.tslt("Choose one"))); out.write(_jsp_string12, 0, _jsp_string12.length); Vector v = PRP.getAllPurpose(); for (int i = 0; i < v.size(); i++) { votblPurpose vo = (votblPurpose) v.elementAt(i); int PurposeID = vo.getPurposeID(); String PurposeName = vo.getPurposeName(); if (CE_Survey.getPurpose() == PurposeID) { out.write(_jsp_string13, 0, _jsp_string13.length); out.print((PurposeID)); out.write(_jsp_string14, 0, _jsp_string14.length); out.print((PurposeName)); out.write(_jsp_string12, 0, _jsp_string12.length); } else { out.write(_jsp_string15, 0, _jsp_string15.length); out.print((PurposeID)); out.write('>'); out.print((PurposeName)); out.write(_jsp_string12, 0, _jsp_string12.length); } } out.write(_jsp_string16, 0, _jsp_string16.length); out.print((trans.tslt("Scale Range Chosen"))); out.write(_jsp_string17, 0, _jsp_string17.length); out.print((CE_Survey.getRatScale())); out.write(_jsp_string18, 0, _jsp_string18.length); out.print((trans.tslt("Rating Task"))); out.write(_jsp_string19, 0, _jsp_string19.length); out.print((trans.tslt("Select"))); out.write(_jsp_string20, 0, _jsp_string20.length); out.print((trans.tslt("Rating Task"))); out.write(_jsp_string21, 0, _jsp_string21.length); out.print((trans.tslt("Scale Description"))); out.write(_jsp_string22, 0, _jsp_string22.length); String query2 = ""; boolean dunAddPR = false; int iRatingTaskID = SVR.getRatingTaskID(CE_Survey.getSurvey_ID()); if (iRatingTaskID != 0) dunAddPR = true; boolean anyRecord = false; boolean anyscale = false; Vector vRT = RT.getRatingTask(CE_Survey.getSurvey_ID(), dunAddPR, CE_Survey.getPurpose()); for (int i = 0; i < vRT.size(); i++) { anyRecord = true; votblRatingTask vo = (votblRatingTask) vRT.elementAt(i); int RatID = vo.getRatingTaskID(); String RatName = vo.getRatingTask(); String ScaleType = vo.getScaleType(); out.write(_jsp_string23, 0, _jsp_string23.length); if (CE_Survey.getPurpose() != 9) { out.write(_jsp_string24, 0, _jsp_string24.length); out.print((RatID)); out.write(_jsp_string25, 0, _jsp_string25.length); } else { if (RatID != 2 && RatID != 3) { out.write(_jsp_string26, 0, _jsp_string26.length); out.print((RatID)); out.write(_jsp_string27, 0, _jsp_string27.length); } else { out.write(_jsp_string28, 0, _jsp_string28.length); out.print((RatID)); out.write(_jsp_string29, 0, _jsp_string29.length); } } out.write(_jsp_string30, 0, _jsp_string30.length); out.print((RatName)); out.write(_jsp_string31, 0, _jsp_string31.length); out.print(("selScaleDesc" + RatID)); out.write(_jsp_string32, 0, _jsp_string32.length); Vector vScale = RS.getRatingScale(CE_Survey.getRatScale(), ScaleType, CE_Survey.get_survOrg()); for (int j = 0; j < vScale.size(); j++) { votblScale voS = (votblScale) vScale.elementAt(j); anyscale = true; int ScaleID = voS.getScaleID(); String ScaleDesc = voS.getScaleDescription(); out.write(_jsp_string33, 0, _jsp_string33.length); out.print((ScaleID)); out.write('>'); out.print((ScaleDesc)); out.write(_jsp_string34, 0, _jsp_string34.length); } out.write(_jsp_string35, 0, _jsp_string35.length); } if (anyRecord == false && CE_Survey.getPurpose() != 0) { out.write(_jsp_string36, 0, _jsp_string36.length); out.print( (trans.tslt("All the rating tasks under this purpose of survey have been added"))); out.write(_jsp_string37, 0, _jsp_string37.length); } out.write(_jsp_string38, 0, _jsp_string38.length); if (anyRecord && anyscale) { out.write(_jsp_string39, 0, _jsp_string39.length); out.print((trans.tslt("Add"))); out.write(_jsp_string40, 0, _jsp_string40.length); } out.write(_jsp_string41, 0, _jsp_string41.length); out.print((trans.tslt("Close"))); out.write(_jsp_string42, 0, _jsp_string42.length); } out.write(_jsp_string43, 0, _jsp_string43.length); }
private void _jspService( javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, com.caucho.jsp.PageContextImpl pageContext, javax.servlet.ServletContext application, javax.servlet.http.HttpSession session, TagState _jsp_state) throws Throwable { javax.servlet.jsp.JspWriter out = pageContext.getOut(); final javax.el.ELContext _jsp_env = pageContext.getELContext(); javax.servlet.ServletConfig config = getServletConfig(); javax.servlet.Servlet page = this; javax.servlet.jsp.tagext.JspTag _jsp_parent_tag = null; com.caucho.jsp.PageContextImpl _jsp_parentContext = pageContext; response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); // Author: Dai Yong in June 2013 out.write(_jsp_string0, 0, _jsp_string0.length); CP_Classes.Database Database; synchronized (pageContext.getSession()) { Database = (CP_Classes.Database) pageContext.getSession().getAttribute("Database"); if (Database == null) { Database = new CP_Classes.Database(); pageContext.getSession().setAttribute("Database", Database); } } out.write(_jsp_string1, 0, _jsp_string1.length); CP_Classes.Login logchk; synchronized (pageContext.getSession()) { logchk = (CP_Classes.Login) pageContext.getSession().getAttribute("logchk"); if (logchk == null) { logchk = new CP_Classes.Login(); pageContext.getSession().setAttribute("logchk", logchk); } } out.write(_jsp_string2, 0, _jsp_string2.length); Coach.LoginStatus LoginStatus; synchronized (pageContext.getSession()) { LoginStatus = (Coach.LoginStatus) pageContext.getSession().getAttribute("LoginStatus"); if (LoginStatus == null) { LoginStatus = new Coach.LoginStatus(); pageContext.getSession().setAttribute("LoginStatus", LoginStatus); } } out.write(_jsp_string1, 0, _jsp_string1.length); Coach.Coach Coach; synchronized (pageContext.getSession()) { Coach = (Coach.Coach) pageContext.getSession().getAttribute("Coach"); if (Coach == null) { Coach = new Coach.Coach(); pageContext.getSession().setAttribute("Coach", Coach); } } out.write(_jsp_string3, 0, _jsp_string3.length); String username = (String) session.getAttribute("username"); if (!logchk.isUsable(username)) { out.write(_jsp_string4, 0, _jsp_string4.length); } else { if (request.getParameter("add") != null) { if (request.getParameter("Name") != null) { String name = request.getParameter("Name"); String link = ""; if (request.getParameter("Link") != "") { link = request.getParameter("Link"); } // check whether SlotGroup name already exists in database Boolean Exist = false; Vector v = Coach.getAllCoach(); for (int i = 0; i < v.size(); i++) { voCoach vo = (voCoach) v.elementAt(i); String coachName = vo.getCoachName(); // System.out.println("Existing Schedule Name:"+slotGroupName); if (name.trim().equalsIgnoreCase((coachName.trim()))) { Exist = true; System.out.println("Same Coach Name"); } } if (!Exist) { try { boolean add = Coach.addCoach(name, link); if (add) { out.write(_jsp_string5, 0, _jsp_string5.length); } else { } } catch (Exception SE) { System.out.println(SE); } } else { out.write(_jsp_string6, 0, _jsp_string6.length); } } } out.write(_jsp_string7, 0, _jsp_string7.length); } out.write(_jsp_string8, 0, _jsp_string8.length); }
/** * This is the main controller logic for item selection servlet. This determines whether to show a * list of items for a WorkOrder, add a item, edit a item's detail information, or delete a item. * The product_action parameter is past to this servlet to determine what action to perform. The * product_action parameter is a button defined by JSPs related to product presentation screens. * * <p>The default action is to show all product related to a parent WorkOrder. * * @param req HttpServlet request * @param resp HttpServlet response */ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { WorkOrderDetailRemote workorderdetEJBean = null; securityChecks(req, resp); // Get the current session HttpSession session = req.getSession(false); if (session == null) return; String sTmp = ""; // Get a new business logic EJB (custInfoEJBean) USFEnv.getLog().writeDebug("getting buslogic EJB", this, null); try { workorderdetEJBean = workorderdetHome.create(); USFEnv.getLog().writeDebug("EJBean Created", this, null); } catch (CreateException e) { String errorMsg = "Critical Exception in ItemsServlet"; USFEnv.getLog().writeCrit(errorMsg + " failed EJB creation", this, e); errorJSP(req, resp, errorMsg); return; } catch (RemoteException e) { String errorMsg = "Critical Exception in ItemsServlet"; USFEnv.getLog().writeCrit(errorMsg + " failed EJB connect", this, e); errorJSP(req, resp, errorMsg); return; } catch (Exception e) { String errorMsg = "Critical Exception no EJB created"; USFEnv.getLog().writeCrit(errorMsg + " failed EJB creation", this, e); errorJSP(req, resp, errorMsg); return; } try { // Button user pressed in the itemselection.jsp String sJSPAction = req.getParameter("product_action"); USFEnv.getLog().writeWarn("product_action from JSP: " + sJSPAction, this, null); short year = Short.valueOf((String) session.getValue("Iyear")).shortValue(); long customerId = Long.valueOf((String) session.getValue("rcustId")).longValue(); long applicationId = Long.valueOf((String) session.getValue("rappid")).longValue(); long workorderId = 0; long bkId = 0; long billkeyId = 0; long bsId = 0; long wodId = 0; String editflag = ""; String bsNm = ""; java.sql.Date strtDate = null; java.sql.Date endDate = null; String prodError = ""; // Check to make sure session does have an WorkOrder ID if (session.getValue("WorkOrderId") != null) { // If Yes get the parent WorkOrder ID from session workorderId = Long.valueOf((String) session.getValue("WorkOrderId")).longValue(); } // Button Action from JSP is empty then show the Default page of the // Product Listing. if (USFUtil.isBlank(sJSPAction)) { USFEnv.getLog().writeDebug("Display product list for FRN.", this, null); // list items for parent Work Order Number Vector billingsystems = null; WrkOrdrDets workorderdets = new WrkOrdrDets(); billingsystems = workorderdets.getBillingSystems(); req.setAttribute("BillingSystems", billingsystems); for (int s = 0; s < billingsystems.size(); s++) USFEnv.getLog() .writeDebug("INSIDE BILLING SYSTEMS " + billingsystems.elementAt(s), this, null); listProducts(workorderId, workorderdetEJBean, session, req, resp); return; } // Button action from JSP is to Add a new Item else if (sJSPAction.equals("add")) { // Remove the Product Object from session session.removeValue("prodObj"); editflag = "addnew"; req.setAttribute("editflag", editflag); // Read the Item and the Billing System for adding the New // Item. String formProdBsId = (String) req.getParameter("formProdId"); String formProdId = formProdBsId.substring(0, formProdBsId.indexOf("|")); String formProdName = formProdBsId.substring(formProdBsId.indexOf("|") + 1); long rscId = (new Long(formProdId).longValue()); // bsId = (new Long( formBsId ).longValue()) ; String billSystem = formProdName.substring(0, formProdName.indexOf("-")); String itemName = formProdName.substring(formProdName.indexOf("-") + 1); BlgSys blgSys = new BlgSys(); bsId = blgSys.getBsId(billSystem); // Create db connection for EJB workorderdetEJBean.connect(); // Get the WorkOrder Object. WorkOrder woObj = workorderdetEJBean.getWorkOrderInfo(workorderId); // Get the list of Billing Keys for the Billing System. String[] blgKeys = workorderdetEJBean.getBillingKeys(customerId, bsId); // Release db connection for EJB workorderdetEJBean.release(); // If no Billing Keys for the Billing System selected then redirect // to the List Items screen and show the error Message. if (blgKeys == null) { BlgSys blgsys = new BlgSys(); Hashtable bSysList = (Hashtable) blgsys.searchBlgSys(); // Hashtable bSysList = (Hashtable) USFEnv.getBillSystems(); // Set the JSP error message req.setAttribute("errorMsg", "No BTNs for Billing System " + billSystem); // list products for parent WorkOrder Number listProducts(workorderId, workorderdetEJBean, session, req, resp); return; } req.setAttribute("prodcredit", "N"); req.setAttribute("bsystem", String.valueOf(bsId)); req.setAttribute("bkList", blgKeys); req.setAttribute("prodId", formProdId); String wid = String.valueOf(workorderId); session.putValue("workorderId", wid); req.setAttribute("billingsystem", billSystem); req.setAttribute("itemname", itemName); // Include the JSP to Edit Product includeJSP(req, resp, ITEM_JSP_PATH, "editItem"); return; } // Button action from JSP is to Edit a Product else if (sJSPAction.equals("edit")) { String bsysid = req.getParameter("bsId"); session.putValue("bysysidforedit", bsysid); wodId = (new Long((String) req.getParameter("wodId"))).longValue(); // bkId = (new Long( (String) req.getParameter("bkId"))).longValue() ; session.putValue("workorderdetid", String.valueOf(wodId)); bsId = (new Long((String) req.getParameter("bsId"))).longValue(); BlgSys blgSys = new BlgSys(); bsNm = blgSys.getBsName(bsId); // Create db connection for EJB workorderdetEJBean.connect(); // WorkOrder woObj = workorderdetEJBean.getWorkOrderInfo(workorderId); // Get the WorkOrder Number Object WrkOrdrDets wodets_obj = new WrkOrdrDets(); wodets_obj = workorderdetEJBean.getProductInfo(wodId); // Get the List of Billing Keys for the Billing System. String[] blgKeys = workorderdetEJBean.getBillingKeys(customerId, bsId); // Check if the Item has any Credits. If any credits then Billing // Key is not Editable else Editable. if (workorderdetEJBean.hasCredits(wodId)) { req.setAttribute("prodcredit", "Y"); } else { req.setAttribute("prodcredit", "N"); } // Release db connection for EJB workorderdetEJBean.release(); // If Item Object is not null (which generally is the case) then // set the Attributes for the JSP. if (wodets_obj != null) { // Put the Item Object in session editflag = "edit"; session.putValue("wodets", wodets_obj); req.setAttribute("editflag", editflag); // Set the attributes for the Billing System, Billing Key List, req.setAttribute("bkList", blgKeys); req.setAttribute("bsname", bsNm); // Include the JSP to Edit the Item. includeJSP(req, resp, ITEM_JSP_PATH, "editItem"); return; } // If Item Object is null (which generally should not Occur) show // the Default page of Item List for the WorkOrder Number else { // Set the JSP error message req.setAttribute( "errorMsg", "Product Key - " + wodId + " Information not available in the Data Base"); // list items for parent WorkOrder Number listProducts(workorderId, workorderdetEJBean, session, req, resp); return; } } // Button action from JSP is to Delete an Item else if (sJSPAction.equals("delete")) { String formWodId = req.getParameter("wodId"); wodId = (new Long((String) req.getParameter("wodId"))).longValue(); // Create db connection for EJB workorderdetEJBean.connect(); // Delete the Item if (workorderdetEJBean.deleteProduct(wodId)) { req.setAttribute("errorMsg", "Product Key - " + wodId + " Deleted"); } else { req.setAttribute( "errorMsg", "Deletion Failed. Product Key - " + wodId + " is associated with amounts."); } // Release db connection for EJB workorderdetEJBean.release(); // Show the Item List screen listProducts(workorderId, workorderdetEJBean, session, req, resp); return; } // Button action from JSP is to Save a Product. This includes Insertion // of New Product or Updation of an Existing Product. else if (sJSPAction.equals("save")) { boolean save = false; boolean newProd = false; // long qty=0; // Read the Billing System Id String formBsId = (String) req.getParameter("bs_id"); String bsysid = (String) req.getParameter("bsysid"); /* String trans_type = (String) req.getParameter("trans_type"); //String quantity = (String) req.getParameter("qty"); String quantity=""; if (!(req.getParameter("qty").equals(""))) { quantity=(String) req.getParameter("qty"); qty = (new Long(quantity).longValue()); } */ String prod_stat = (String) req.getParameter("prod_stat"); double nrcg_dscnt = (new Double((String) req.getParameter("NonRecurringDiscount"))).doubleValue(); double rcg_dscnt = (new Double((String) req.getParameter("RecurringDiscount"))).doubleValue(); String start_month = (String) req.getParameter("strt_month"); String start_day = (String) req.getParameter("strt_day"); String start_year = (String) req.getParameter("strt_year"); String end_month = (String) req.getParameter("end_month"); String end_day = (String) req.getParameter("end_day"); String end_year = (String) req.getParameter("end_year"); String start_date = start_month + "-" + start_day + "-" + start_year; String end_date = end_month + "-" + end_day + "-" + end_year; long wrkordrid = (new Long((String) session.getValue("WorkOrderId"))).longValue(); String for_editing = req.getParameter("for_editing"); String for_new = req.getParameter("for_new"); String formBkId = (String) req.getParameter("bk_id"); String formBKId = formBkId.substring(0, formBkId.indexOf("|")); String formBTN = formBkId.substring(formBkId.indexOf("|") + 1); billkeyId = (new Long(formBKId)).longValue(); try { bsId = (new Long((String) req.getParameter("bs_id"))).longValue(); } catch (Exception e) { USFEnv.getLog().writeDebug("Exception is " + e, this, null); } RHCCBlgKeys blgkeys = new RHCCBlgKeys(); if (for_editing.equals("editing")) { blgkeys.setRbkId(billkeyId); blgkeys.setRbkKeys(formBTN); blgkeys.setBsId(new Long(bsysid).longValue()); } if (for_new.equals("new")) { blgkeys.setRbkId(billkeyId); blgkeys.setRbkKeys(formBTN); blgkeys.setBsId(bsId); } int index = 0; WrkOrdrDets wod_obj = new WrkOrdrDets(); // wod_obj.setTxTyp(trans_type); // wod_obj.setQty(qty); wod_obj.setNonRcrgDscnt(nrcg_dscnt); wod_obj.setRcrgDscnt(rcg_dscnt); wod_obj.setRBKID(billkeyId); wod_obj.setWodStat(prod_stat); wod_obj.setWOID(wrkordrid); if (!(start_date.equals(""))) { strtDate = new java.sql.Date((new SimpleDateFormat("MM-dd-yyyy")).parse(start_date).getTime()); wod_obj.setStrtDat(strtDate); } // Else if the Start Date is null update the Item Object Date to // null else { wod_obj.setStrtDat(null); } // If Item Service End Date is not null read the date and update // the Item Object with the date if (!(end_date.equals(""))) { endDate = new java.sql.Date((new SimpleDateFormat("MM-dd-yyyy")).parse(end_date).getTime()); wod_obj.setEndDat(endDate); } // Else if the End Date is null update the Item Object Date to null else { wod_obj.setEndDat(null); } // Check if the Start Date is after the End Date or equals End Date if ((strtDate != null) && (endDate != null) && (strtDate.after(endDate))) { prodError = "Product Service Start Date is after Product Service End Date. \n"; index = 1; } else if ((strtDate != null) && (endDate != null) && (strtDate.equals(endDate))) { prodError = "Product Service Start Date equals Product Service End Date. \n"; } workorderdetEJBean.connect(); if (for_editing.equals("editing")) { long workorderdetID = (new Long((String) session.getValue("workorderdetid"))).longValue(); wod_obj.setWODID(workorderdetID); if (index == 0) { save = workorderdetEJBean.saveProduct(wod_obj); } if (save) { prodError = prodError + "<BR> Product Key - " + wod_obj.getWODID() + " Information updated"; req.setAttribute("error", prodError); } else { prodError = prodError + "<BR> Failed to update Product Information"; req.setAttribute("error", prodError); } } if (for_new.equals("new")) { if (index == 0) { int prodId = Integer.parseInt(req.getParameter("prod_Id")); wod_obj.setProd_id(prodId); save = workorderdetEJBean.saveProduct(wod_obj); } if (save) { prodError = prodError + "<BR> Product Key - " + wod_obj.getWODID() + " Information Saved"; req.setAttribute("error", prodError); } else { prodError = prodError + "<BR> Failed to Save Product Information"; req.setAttribute("error", prodError); } } workorderdetEJBean.release(); listProducts(wrkordrid, workorderdetEJBean, session, req, resp); } } // End of try block catch (Exception e) { if (workorderdetEJBean != null) { // calling bean release method try { workorderdetEJBean.release(); } catch (Exception ex) { USFEnv.getLog().writeCrit(" Exception in calling release() method ", this, e); } } String errorMsg = "Processing Exception in Items Servlet: "; USFEnv.getLog().writeCrit(errorMsg, this, e); errorJSP(req, resp, errorMsg); } // End of catch block } // end of doPost()