Background control
The filter has implemented a coding problem with string op = Request.getparameter ("Op"), if ("Addcategory". Equals (OP)) {addcategory (request,response);} else if ("Showallcategories". Equals (OP)) {showallcategories (request,response);} else if ("Addbookui". Equals (OP)) { Addbookui (request,response);} else if ("Addbook". Equals (OP)) {Addbook (request,response);} else if ("Showallbooks". Equals (OP)) {Showallbooks (Request , response);} else if ("Login". Equals (OP)) {login (request,response);} else if ("Managerlogout". Equals (OP)) {Managerlogout (Request, Response);} First, add classification (Add classification module--link) 1. Add a category Add the form data to Category 2. Call the business logic method to add to the database in 3. Add success Prompt Response.getwriter (). Write ("<font color= ' green ' > Save Success </font>"); 4. otherwise Response.getwriter (). Write ("<font color= ' Red ' > Save failed, category already exists </font>"); Show all categories (Query classification module-link) 1. Call the business method to query all classification 2. Set the categories to 3 in the request domain. Forward to/manager/showallcategories.jsp three, link to add Book page (add book module-link) 1. Call the business method to query all classification 2. Set the categories to 3 in the request domain. Forward to/manager/addbookui.jsp four, add book (Add book Module-link) 1. Determine if enctype is multipart, and if it is not a hint, return RESPONSE.GETWRiter (). Write ("Please select the correct enctype type <a href= '" +request.getcontextpath () + "/manager/addbookui.jsp" > Return operation </a> "); 2. Create a file Upload object, parse the request parameters, create a book object 3. Traverse the requested object parsed to, and if it is a normal field, get the field name and value directly from the Beanutils tool set to book object 4. If not upload field 1). Get the file name, unique file name + extension filenameutils.getextension, and set the file name to book object 2). Gets the file storage path that is created if the path does not exist in the directory 3). Build subdirectories to store subdirectories in book's Path 4). Write the upload file to the storage path in 5. Call the business method to add the book to the Database Request.setattribute ("MSG", "<script type= ' text/javascript ' >alert (' File saved successfully '); </script > "); 6. In order to regain the classification of books, to re-check all categories and then forward to/manager/addbookui.jsp five, display books (View book module-link) 1. Gets the request on page 2. Call the Business method query Pagebean object Findbookpagebypagenum (pagenum) 3. Set the URL address, Pb.seturl (Request.getcontextpath () + "/servlet/managerservlet?op=showallbooks"); 4. Set the page to 5 in the request domain. Forward to "/manager/listbooks.jsp"
Front desk Control
String op = Request.getparameter ("Op"), if ("Showindex". Equals (OP)) {Showindex (request, response);} else if (" Listbookbycategory ". Equals (OP)) {listbookbycategory (request,response);} else if (" Buybook ". Equals (OP)) {Buybook ( Request,response);} else if ("Deloneitem". Equals (OP)) {Deloneitem (request,response);} else if ("Delmultiitem". Equals (OP)) {Delmultiitem ( request, response);} else if ("Changeitemnum". Equals (OP)) {changeitemnum (request,response);} else if ("Regist". Equals (OP)) {Regist (Request , response);} else if ("active". Equals (OP)) {active (request,response);} else if ("Login". Equals (OP)) {login (request,response);} else if ("Logout". Equals (OP)) {logout (request,response);} else if ("getorders". Equals (OP)) {getorders (request,response);} else if ("Showorders". Equals (OP)) {showorders (request,response);} else if ("Pay". Equals (OP)) {Pay (request,response);} else if ("Payui". Equals (OP)) {Payui (request,response);} First, display the front desk homepage (Home module--link) 1. Query all classifications, set the collection categories of the taxonomy to the Request field 2. Gets the requested page number, calling the business method to find a book by page number to get a pagebeaN Object 3. Set the URL, set page to 4 in the Request field. Forward to Listbooks.jsp II, search all books by Category 1. Query all classifications, set the collection categories of the taxonomy to the Request field 2. Get Request Parameters: Page number and Category ID (categoryId) 3. Call the business method to find the Pagebean object by page number and by category Id4. Set the URL, set the object Page5 in the request domain. Forward to listbooks.jsp III, purchase link 1. Get the book bookId2. Call the business method to find book Findbookid (bookId) 3 through BookId. Get the session and find the shopping cart Cart4 from the session field. If the cart is empty, create a Cart object and set the cart to 5 in the session field. Add a book to your shopping cart 6. Ajax response data, Response.getwriter (). Write ("<font color= ' Red ' > successful purchase, if you want to see the items you purchased, please click on the shopping cart </font"); Iv. Delete individual item 1. Gets the request parameter bookdId2. Session Field Lookup Cart3. Remove the bookid4 in the shopping cart. Redirect to showcart.jsp Five, delete multiple items 1. Gets the requested IDs an array of 2. Gets the CART3 in the session. Traverse IDs and remove 4 from the shopping cart. Redirect to/showcart.jsp VI, change the number of shopping items 1. Get the quantity and book number Num/bookid2. The obtained number is strongly transferred to an int type newnum, to be treated as an exception 3. Gets the session object and gets the shopping cart 4 of the Session object. If the shopping cart is not empty and the shopping item is larger than 0 by the book number to find the item, set the number of the shopping item to 5. Redirect to Showcart.jsp VII, registered user (customer) 1. Injects the requested registration information into the Customer object 2. Set up customer Id/code (activation code) 3. Call the business method to register the user Registcustomer (c) 4. Registration Success Message Response.getwriter (). Write ("Registration succeeded, the activation code has been sent to your" + c.getemail () + "letter ..."); 5. If there is an exception at the time of registration, the registration failed # Send message 1. Opens a SendMail class dedicated to sending messages to thread 2. Constructs a structure that receives customer information and request addressesBuild function 3. Define props Collection Storage protocol ... 4. Create session, mememessage (mail message) 5. Set sender, receive type, subject, Content message.setcontent ("Welcome to join the Dark horse <br/> to activate your account <a href= ' http://localhost:8080/" +context+ "/ Servlet/clientservlet?op=active&username= "+c.getusername () +" &code= "+c.getcode () +" ' > Activation </a> Welcome harassment ~ "," Text/html;charset=utf-8 "); Save message change information, message.savechanges (); 6. Through the session object to get a rocket, set user name, password connect7. Set Send Messsage object, and recipient eight, activate mail processing 1. Get the user name and Activation Code 2. Call the business method to activate Activedcustomer (username, code) 3. Hint Information response.getwriter (). Write ("Activation succeeded"); Response.setheader ("Refresh", "2; Url= "+request.getcontextpath ()); 4. Otherwise prompt server busy nine, login operation 1. Gets the user name, password request parameter 2. Call the business method to validate Logincustomer (username, password) 3. If the resulting user is empty, the prompt information Response.getwriter (). Write ("Prompt for user name and password error or inactive, 2 seconds after jumping to login page"); Response.setheader ("Refresh", "2; Url= "+request.getcontextpath () +"/login.jsp "); 4. Otherwise, set the user customer to 5 in the session field. Prompt for Login Success response.getwriter (). Write ("Login successful, skip to home page after 2 seconds"); Response.setheader ("Refresh", "2; Url= "+request.getcontextpath ()); X. Logout operation 1. Removes the user Customer2 in the session domain. Tip Information Response.getwriter ().Write ("Logout succeeded, jump to login page after 2 seconds"); Response.setheader ("Refresh", "2; Url= "+request.getcontextpath () +"/login.jsp "), Xi. Generate order GetOrder1. Get the Session object and look for Customer2 from the session field. If the user is empty jump Response.sendredirect (Request.getcontextpath () + "/login.jsp"); return;3. Gets the shopping Cart object 4 from the session field. Create Orders object 5. Set the order number Ordersnum, set the total amount, the total quantity, and set the CUSTOMER6 for the order. Traverse Shopping Item 7 in the shopping cart. Get every shopping item 8. Create a LineItem object that stores order Details 9. Set the ID of the order details, set the number, subtotal, set the corresponding book Book10. Add the order details to the order ORDERS11. Call the business method to generate order information genorders (orders); 12. Set the order to the request domain, forward to pay.jsprequest.setAttribute ("O", Orders), Request.getrequestdispatcher ("/pay.jsp"). Forward ( request, response); 12, show Order (my order) showOrders1. Find Customer2 from the session field. If customer is null redirected to/LOGIN.JSP3. Call the business method to get all orders Findordersbycustomerid (C.getid ()) 4. Set the order to the request field in 5. Forward to/showcustomerorders.jsp
Online payment
First, the settlement shopping cart commodity pay1. Get Order number OrderID, amount money, bank type PD_FRPID2. Package parameters url= "http://localhost:8080/" +request.getcontextpath () + "/servlet/paymentresponse" String HMAC = Paymentutil.buildhmac (...); 3. Set the parameters to the request domain and forward to SURE.JSP4. sure.jsp form submitted to HTTPS://WWW.YEEPAY.COM/APP-MERCHANT-PROXY/NODE5. Set up the Paymentresponse class to get the value 6 in the request domain. Verify that the data is valid PAYMENTUTIL.VERIFYCALLBACK7. If a valid r1_code:1 represents a successful r9_btype:2 on behalf of a server point-to-point communication, setting 2 must write Sucessif ("1". Equals (R1_code ) {if ("2". Equals (R9_btype)) {response.getwriter (). Write ("Success");}} 8. If if ("1". Equals (R1_code) succeeds, call business method Findordersbyordersnum (R6_order) 9. Change the status of the query to the order, and then call the business method update order 10. Hint Information response.getwriter (). Write ("Payment succeeded!,<a href= ' http://localhost:8080/" +request.getcontextpath () + "/ Showcustomerorders.jsp ' > Click Back to Order Page </a> "), my order (payment operation) 1. Gets the session object, looking for Customer2 from the session. If NULL jumps to Response.sendredirect (Request.getcontextpath () + "/login.jsp"); return;3. Gets the order number, calling the business method to query the order 4. Set the query to the request field in 5. Forward to/pay.jsp
Permission control
First, the user login 1. Gets the requested parameter username&password2. The business layer authenticates the login and returns the User Object 3. Determines whether the user is empty or not, and redirects manager/index.jsp;4 in the session field if not set to null. If empty response.getwriter (). Write ("Bad user name or password, log in again"); Jump to login/login.jsp. User Logoff 1. Removes the User object 2 from the Session field. REDIRECT/login/login.jsp#### permission filter (based on URI address filtering permissions issue) 1. For login, logout, get Ajax engine does not need to filter, so these are used direct release 2. Gets the request address Getrequesturi (), gets the request parameter getquerystring (), if the request parameter is not empty, stitching the URI address 3. Replace the application name with an empty string, in order to determine the address in the following and Permissions 4. Gets the user object in session, and if user is empty, redirects to the background login page/LOGIN/LOGIN.JSP5. Creates a menu collection of menus, which is used as a collection of queries in the store database 6. Call the business method, find the Role permission set Service.finduserroles (user) by user, 7. Iterates over the permission collection, then obtains each permission object, gets the menu collection service.findmenurole (role) through the permission object; 8. Add the Found menu collection to menus 9. Define a variable haspermission to determine if the permission is 10. Traverse menus to determine if the address in the menu module is equal to the requested address, and if the equality setting is haspermission to true,break;11. If Haspermission is true, direct release, otherwise prompt does not have permission
Javaweb control Layer-Online bookstore (22)