├── .classpath ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ └── feature_request.yml └── pull_request_template.md ├── .gitignore ├── .project ├── .settings ├── .jsdtscope ├── org.eclipse.jdt.core.prefs ├── org.eclipse.m2e.core.prefs ├── org.eclipse.wst.common.component ├── org.eclipse.wst.common.project.facet.core.xml ├── org.eclipse.wst.jsdt.ui.superType.container ├── org.eclipse.wst.jsdt.ui.superType.name └── org.eclipse.wst.validation.prefs ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dummy_Database.md ├── Jenkinsfile ├── Procfile ├── README.md ├── WebContent ├── Animated buttons ├── CustomerHome.html ├── CustomerLogin.html ├── CustomerRegister.html ├── META-INF │ └── MANIFEST.MF ├── Photo.jpg ├── SellerHome.html ├── SellerLogin.html ├── WEB-INF │ └── web.xml ├── favicons │ ├── android-chrome-192x192.png │ ├── android-chrome-512x512.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ └── site.webmanifest ├── index.html ├── loader.gif ├── login.html ├── logo.png ├── payment.html └── styles.css ├── appspec.yaml ├── buildspec.yaml ├── pom.xml ├── scripts ├── start_server.sh └── stop_server.sh ├── setup └── CreateDatastore.sql └── src └── main ├── java ├── com │ └── bittercode │ │ ├── constant │ │ ├── BookStoreConstants.java │ │ ├── ResponseCode.java │ │ └── db │ │ │ ├── BooksDBConstants.java │ │ │ └── UsersDBConstants.java │ │ ├── model │ │ ├── Address.java │ │ ├── Book.java │ │ ├── Cart.java │ │ ├── StoreException.java │ │ ├── User.java │ │ ├── UserRole.java │ │ └── package-info.java │ │ ├── service │ │ ├── BookService.java │ │ ├── UserService.java │ │ └── impl │ │ │ ├── BookServiceImpl.java │ │ │ └── UserServiceImpl.java │ │ └── util │ │ ├── DBUtil.java │ │ ├── DatabaseConfig.java │ │ └── StoreUtil.java └── servlets │ ├── AboutServlet.java │ ├── AddBookServlet.java │ ├── BuyBooksServlet.java │ ├── CartServlet.java │ ├── CheckoutServlet.java │ ├── CustomerLoginServlet.java │ ├── CustomerRegisterServlet.java │ ├── ErrorHandlerServlet.java │ ├── LogoutServlet.java │ ├── ProcessPaymentServlet.java │ ├── ReceiptServlet.java │ ├── RemoveBookServlet.java │ ├── SellerLoginServlet.java │ ├── StoreBookServlet.java │ ├── UpdateBookServlet.java │ └── ViewBookServlet.java └── resources └── application.properties /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Create a report to help us improve. Report bugs found while using the project 3 | title: "[BUG]" 4 | labels: [bug] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: "Provide a general summary of the issue in the Title above" 9 | - type: textarea 10 | id: description 11 | attributes: 12 | label: Description 13 | description: Provide a general summary of the issue in the Title above 14 | validations: 15 | required: true 16 | - type: input 17 | id: expectedbhv 18 | attributes: 19 | label: Expected behavior 20 | description: Tell us what should happen 21 | validations: 22 | required: true 23 | - type: input 24 | id: actualbhv 25 | attributes: 26 | label: Actual behavior 27 | description: Tell us what happens instead 28 | validations: 29 | required: true 30 | - type: input 31 | id: possiblefix 32 | attributes: 33 | label: Possible fix 34 | description: Not obligatory, but suggest a fix or reason for the bug 35 | validations: 36 | required: false 37 | - type: textarea 38 | id: steps 39 | attributes: 40 | label: Steps to reproduce 41 | description: | 42 | Provide a link to a live example, or an unambiguous set of steps to 43 | reproduce this bug. Include code to reproduce, if relevant 44 | placeholder: | 45 | 1. 46 | 2. 47 | 3. 48 | 4. 49 | validations: 50 | required: true 51 | - type: textarea 52 | id: context 53 | attributes: 54 | label: Context 55 | description: How has this bug affected you? What were you trying to accomplish? 56 | validations: 57 | required: true 58 | - type: textarea 59 | id: extrainformation 60 | attributes: 61 | label: Additional information 62 | description: Is there anything else we should know about this bug? 63 | validations: 64 | required: false 65 | 66 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest features, propose improvements, discuss new ideas. 3 | title: "[FEATURE]" 4 | labels: [enhancement] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: Provide a general summary of the issue in the Title above 9 | - type: textarea 10 | id: description 11 | attributes: 12 | label: Detailed description 13 | description: Provide a detailed description of the change or addition you are proposing 14 | validations: 15 | required: true 16 | - type: textarea 17 | id: context 18 | attributes: 19 | label: Context 20 | description: | 21 | Why is this change important to you? How would you use it? 22 | How can it benefit other users? 23 | validations: 24 | required: true 25 | - type: textarea 26 | id: possibleimpl 27 | attributes: 28 | label: Possible implementation 29 | description: Not obligatory, but suggest an idea for implementing addition or change 30 | validations: 31 | required: false 32 | - type: textarea 33 | id: extrainformation 34 | attributes: 35 | label: Additional information 36 | description: Is there anything else we should know about this feature? 37 | validations: 38 | required: false 39 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | #### Description of Change 2 | 3 | 9 | 10 | #### References 11 | 12 | 13 | ## Type of change 14 | 15 | 16 | - [ ] Bug fix (non-breaking change which fixes an issue) 17 | - [ ] New feature (non-breaking change which adds functionality) 18 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 19 | - [ ] This change requires a documentation update 20 | 21 | #### Checklist 22 | 23 | 24 | - [ ] Added description of change 25 | - [ ] Relevant documentation/comments is changed or added 26 | - [ ] Search previous suggestions before making a new one, as yours may be a duplicate. 27 | - [ ] I have performed a self-review of my own code by running the project in local 28 | - [ ] I acknowledge that all my contributions will be made under the project's license. 29 | 30 | Notes: 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /build/ 3 | .classpath 4 | .settings 5 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | onlinebookstore 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.wst.common.project.facet.core.builder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.m2e.core.maven2Nature 31 | org.eclipse.jem.workbench.JavaEMFNature 32 | org.eclipse.wst.common.modulecore.ModuleCoreNature 33 | org.eclipse.wst.common.project.facet.core.nature 34 | org.eclipse.jdt.core.javanature 35 | org.eclipse.wst.jsdt.core.jsNature 36 | 37 | 38 | 39 | 1665573956898 40 | 41 | 30 42 | 43 | org.eclipse.core.resources.regexFilterMatcher 44 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | enableParallelJavaIndexSearch=true 3 | org.eclipse.jdt.core.builder.annotationPath.allLocations=disabled 4 | org.eclipse.jdt.core.builder.cleanOutputFolder=clean 5 | org.eclipse.jdt.core.builder.duplicateResourceTask=warning 6 | org.eclipse.jdt.core.builder.invalidClasspath=abort 7 | org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore 8 | org.eclipse.jdt.core.builder.resourceCopyExclusionFilter= 9 | org.eclipse.jdt.core.circularClasspath=warning 10 | org.eclipse.jdt.core.classpath.exclusionPatterns=enabled 11 | org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error 12 | org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled 13 | org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error 14 | org.eclipse.jdt.core.codeComplete.argumentPrefixes= 15 | org.eclipse.jdt.core.codeComplete.argumentSuffixes= 16 | org.eclipse.jdt.core.codeComplete.camelCaseMatch=enabled 17 | org.eclipse.jdt.core.codeComplete.deprecationCheck=disabled 18 | org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck=disabled 19 | org.eclipse.jdt.core.codeComplete.fieldPrefixes= 20 | org.eclipse.jdt.core.codeComplete.fieldSuffixes= 21 | org.eclipse.jdt.core.codeComplete.forbiddenReferenceCheck=enabled 22 | org.eclipse.jdt.core.codeComplete.forceImplicitQualification=disabled 23 | org.eclipse.jdt.core.codeComplete.localPrefixes= 24 | org.eclipse.jdt.core.codeComplete.localSuffixes= 25 | org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= 26 | org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= 27 | org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= 28 | org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= 29 | org.eclipse.jdt.core.codeComplete.subwordMatch=disabled 30 | org.eclipse.jdt.core.codeComplete.suggestStaticImports=enabled 31 | org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled 32 | org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled 33 | org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore 34 | org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull 35 | org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= 36 | org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault 37 | org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= 38 | org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable 39 | org.eclipse.jdt.core.compiler.annotation.nullable.secondary= 40 | org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled 41 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 42 | org.eclipse.jdt.core.compiler.codegen.lambda.genericSignature=do not generate 43 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 44 | org.eclipse.jdt.core.compiler.codegen.shareCommonFinallyBlocks=disabled 45 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 46 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 47 | org.eclipse.jdt.core.compiler.compliance=1.8 48 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 49 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 50 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 51 | org.eclipse.jdt.core.compiler.doc.comment.support=enabled 52 | org.eclipse.jdt.core.compiler.emulateJavacBug8031744=enabled 53 | org.eclipse.jdt.core.compiler.generateClassFiles=enabled 54 | org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 55 | org.eclipse.jdt.core.compiler.problem.APILeak=warning 56 | org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info 57 | org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning 58 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 59 | org.eclipse.jdt.core.compiler.problem.autoboxing=ignore 60 | org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning 61 | org.eclipse.jdt.core.compiler.problem.deadCode=warning 62 | org.eclipse.jdt.core.compiler.problem.deadCodeInTrivialIfStatement=disabled 63 | org.eclipse.jdt.core.compiler.problem.deprecation=warning 64 | org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled 65 | org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled 66 | org.eclipse.jdt.core.compiler.problem.discouragedReference=warning 67 | org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore 68 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 69 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 70 | org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore 71 | org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore 72 | org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled 73 | org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore 74 | org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning 75 | org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning 76 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 77 | org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning 78 | org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled 79 | org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning 80 | org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning 81 | org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore 82 | org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore 83 | org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=disabled 84 | org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled 85 | org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled 86 | org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public 87 | org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore 88 | org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning 89 | org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore 90 | org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore 91 | org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled 92 | org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore 93 | org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore 94 | org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled 95 | org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public 96 | org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag 97 | org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore 98 | org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled 99 | org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled 100 | org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public 101 | org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore 102 | org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled 103 | org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore 104 | org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore 105 | org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning 106 | org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning 107 | org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore 108 | org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning 109 | org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning 110 | org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error 111 | org.eclipse.jdt.core.compiler.problem.nullReference=warning 112 | org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error 113 | org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning 114 | org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation=ignore 115 | org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning 116 | org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore 117 | org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning 118 | org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore 119 | org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore 120 | org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore 121 | org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning 122 | org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning 123 | org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore 124 | org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore 125 | org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning 126 | org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore 127 | org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore 128 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 129 | org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled 130 | org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning 131 | org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled 132 | org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled 133 | org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info 134 | org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled 135 | org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore 136 | org.eclipse.jdt.core.compiler.problem.tasks=warning 137 | org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning 138 | org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning 139 | org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled 140 | org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning 141 | org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning 142 | org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore 143 | org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore 144 | org.eclipse.jdt.core.compiler.problem.uninternedIdentityComparison=disabled 145 | org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning 146 | org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled 147 | org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info 148 | org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore 149 | org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore 150 | org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore 151 | org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning 152 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore 153 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled 154 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled 155 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled 156 | org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore 157 | org.eclipse.jdt.core.compiler.problem.unusedImport=warning 158 | org.eclipse.jdt.core.compiler.problem.unusedLabel=warning 159 | org.eclipse.jdt.core.compiler.problem.unusedLocal=warning 160 | org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore 161 | org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore 162 | org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled 163 | org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled 164 | org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled 165 | org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning 166 | org.eclipse.jdt.core.compiler.problem.unusedTypeArgumentsForMethodInvocation=warning 167 | org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore 168 | org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning 169 | org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning 170 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 171 | org.eclipse.jdt.core.compiler.release=disabled 172 | org.eclipse.jdt.core.compiler.source=1.8 173 | org.eclipse.jdt.core.compiler.storeAnnotations=disabled 174 | org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled 175 | org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL 176 | org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX 177 | org.eclipse.jdt.core.computeJavaBuildOrder=ignore 178 | org.eclipse.jdt.core.encoding=utf8 179 | org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false 180 | org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 181 | org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line=true 182 | org.eclipse.jdt.core.formatter.align_type_members_on_columns=false 183 | org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false 184 | org.eclipse.jdt.core.formatter.align_with_spaces=false 185 | org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 186 | org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49 187 | org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49 188 | org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49 189 | org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49 190 | org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49 191 | org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0 192 | org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49 193 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 194 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 195 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 196 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 197 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 198 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 199 | org.eclipse.jdt.core.formatter.alignment_for_assertion_message=16 200 | org.eclipse.jdt.core.formatter.alignment_for_assignment=0 201 | org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 202 | org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 203 | org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 204 | org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 205 | org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 206 | org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 207 | org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 208 | org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 209 | org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow=16 210 | org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon=16 211 | org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 212 | org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 213 | org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 214 | org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 215 | org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 216 | org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 217 | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 218 | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 219 | org.eclipse.jdt.core.formatter.alignment_for_record_components=16 220 | org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 221 | org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 222 | org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 223 | org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 224 | org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 225 | org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 226 | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 227 | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 228 | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 229 | org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow=20 230 | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 231 | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 232 | org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 233 | org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 234 | org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 235 | org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 236 | org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 237 | org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 238 | org.eclipse.jdt.core.formatter.blank_lines_after_package=1 239 | org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 240 | org.eclipse.jdt.core.formatter.blank_lines_before_field=0 241 | org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 242 | org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 243 | org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 244 | org.eclipse.jdt.core.formatter.blank_lines_before_method=1 245 | org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 246 | org.eclipse.jdt.core.formatter.blank_lines_before_package=0 247 | org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 248 | org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 249 | org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 250 | org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line 251 | org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line 252 | org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line 253 | org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line 254 | org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line 255 | org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line 256 | org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line 257 | org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line 258 | org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line 259 | org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line 260 | org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line 261 | org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line 262 | org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line 263 | org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line 264 | org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true 265 | org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false 266 | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false 267 | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false 268 | org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true 269 | org.eclipse.jdt.core.formatter.comment.format_block_comments=true 270 | org.eclipse.jdt.core.formatter.comment.format_header=false 271 | org.eclipse.jdt.core.formatter.comment.format_html=true 272 | org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true 273 | org.eclipse.jdt.core.formatter.comment.format_line_comments=true 274 | org.eclipse.jdt.core.formatter.comment.format_source_code=true 275 | org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false 276 | org.eclipse.jdt.core.formatter.comment.indent_root_tags=false 277 | org.eclipse.jdt.core.formatter.comment.indent_tag_description=false 278 | org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert 279 | org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert 280 | org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert 281 | org.eclipse.jdt.core.formatter.comment.line_length=80 282 | org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true 283 | org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true 284 | org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false 285 | org.eclipse.jdt.core.formatter.compact_else_if=true 286 | org.eclipse.jdt.core.formatter.continuation_indentation=2 287 | org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 288 | org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off 289 | org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on 290 | org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false 291 | org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false 292 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true 293 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true 294 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true 295 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true 296 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true 297 | org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true 298 | org.eclipse.jdt.core.formatter.indent_empty_lines=false 299 | org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true 300 | org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true 301 | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true 302 | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true 303 | org.eclipse.jdt.core.formatter.indentation.size=4 304 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert 305 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert 306 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert 307 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert 308 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert 309 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert 310 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert 311 | org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert 312 | org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert 313 | org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert 314 | org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert 315 | org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert 316 | org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert 317 | org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert 318 | org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert 319 | org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert 320 | org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert 321 | org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert 322 | org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert 323 | org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert 324 | org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert 325 | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert 326 | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert 327 | org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert 328 | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert 329 | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert 330 | org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert 331 | org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert 332 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert 333 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert 334 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert 335 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert 336 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert 337 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert 338 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert 339 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert 340 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert 341 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert 342 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert 343 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert 344 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert 345 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert 346 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert 347 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert 348 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert 349 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert 350 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert 351 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert 352 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert 353 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types=insert 354 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert 355 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert 356 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert 357 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert 358 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert 359 | org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert 360 | org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert 361 | org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert 362 | org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert 363 | org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert 364 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert 365 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert 366 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert 367 | org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert 368 | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert 369 | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert 370 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert 371 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert 372 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert 373 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert 374 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert 375 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert 376 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert 377 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert 378 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert 379 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert 380 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert 381 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert 382 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert 383 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert 384 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert 385 | org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert 386 | org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert 387 | org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert 388 | org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert 389 | org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert 390 | org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert 391 | org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert 392 | org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert 393 | org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert 394 | org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert 395 | org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert 396 | org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert 397 | org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert 398 | org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert 399 | org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert 400 | org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert 401 | org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert 402 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert 403 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert 404 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert 405 | org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert 406 | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert 407 | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert 408 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert 409 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert 410 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert 411 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert 412 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert 413 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert 414 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert 415 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert 416 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert 417 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert 418 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert 419 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert 420 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert 421 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert 422 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert 423 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert 424 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert 425 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert 426 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert 427 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert 428 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert 429 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert 430 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert 431 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert 432 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert 433 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert 434 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert 435 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert 436 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert 437 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert 438 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert 439 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert 440 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert 441 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert 442 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert 443 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert 444 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert 445 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types=do not insert 446 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert 447 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert 448 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert 449 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert 450 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert 451 | org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert 452 | org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert 453 | org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert 454 | org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert 455 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert 456 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert 457 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert 458 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert 459 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert 460 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert 461 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert 462 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert 463 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert 464 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert 465 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert 466 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert 467 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert 468 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert 469 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert 470 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert 471 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert 472 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert 473 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert 474 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert 475 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert 476 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert 477 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert 478 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert 479 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert 480 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert 481 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert 482 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert 483 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert 484 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert 485 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert 486 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert 487 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert 488 | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert 489 | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert 490 | org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert 491 | org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert 492 | org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert 493 | org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert 494 | org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert 495 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert 496 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert 497 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert 498 | org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert 499 | org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert 500 | org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert 501 | org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert 502 | org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert 503 | org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert 504 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert 505 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert 506 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert 507 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert 508 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert 509 | org.eclipse.jdt.core.formatter.join_lines_in_comments=false 510 | org.eclipse.jdt.core.formatter.join_wrapped_lines=false 511 | org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never 512 | org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never 513 | org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never 514 | org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false 515 | org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false 516 | org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never 517 | org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never 518 | org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never 519 | org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false 520 | org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never 521 | org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never 522 | org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never 523 | org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never 524 | org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never 525 | org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false 526 | org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false 527 | org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false 528 | org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false 529 | org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line=one_line_never 530 | org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line=one_line_never 531 | org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false 532 | org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never 533 | org.eclipse.jdt.core.formatter.lineSplit=120 534 | org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false 535 | org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false 536 | org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 537 | org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 538 | org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 539 | org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 540 | org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 541 | org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 542 | org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 543 | org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines 544 | org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines 545 | org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines 546 | org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines 547 | org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines 548 | org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines 549 | org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines 550 | org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines 551 | org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines 552 | org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines 553 | org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines 554 | org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true 555 | org.eclipse.jdt.core.formatter.tabulation.char=space 556 | org.eclipse.jdt.core.formatter.tabulation.size=4 557 | org.eclipse.jdt.core.formatter.text_block_indentation=0 558 | org.eclipse.jdt.core.formatter.use_on_off_tags=true 559 | org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false 560 | org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true 561 | org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true 562 | org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false 563 | org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true 564 | org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true 565 | org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true 566 | org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true 567 | org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true 568 | org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true 569 | org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true 570 | org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true 571 | org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator=false 572 | org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true 573 | org.eclipse.jdt.core.incompatibleJDKLevel=ignore 574 | org.eclipse.jdt.core.incompleteClasspath=error 575 | org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter 576 | org.eclipse.jdt.core.timeoutForParameterNameFromAttachedJavadoc=50 577 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [Contact Email Address](https://flowcv.me/shashirajraja). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | [pr]: https://github.com/raise-dev/hacktoberfest/compare 4 | [style]: https://github.com/bbatsov/ruby-style-guide 5 | 6 | Hi there! We're thrilled that you'd like to contribute to Hacktoberfest. Your help is essential for keeping it great. 7 | 8 | Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE). 9 | 10 | ## Opening an issue 11 | 12 | Thank you for taking the time to open an issue, your feedback helps make Hacktoberfest better. 13 | Before opening an issue, please be sure that your issue hasn't already been asked by using [GitHub search](https://help.github.com/articles/searching-issues/) 14 | 15 | Here are a few things that will help us help resolve your issues: 16 | 17 | - A descriptive title that gives an idea of what your issue refers to 18 | - A thorough description of the issue, (one word descriptions are very hard to understand) 19 | - Screenshots (if appropriate) 20 | - Links (if appropriate) 21 | 22 | ## Submitting a pull request 23 | 24 | 0. Clone the repository 25 | 0. Configure and install the dependencies: (See the [README](README.md) for more details) 26 | 0. Make sure the tests pass on your machine: `script/test` 27 | 0. Create a new branch: `git checkout -b my-branch-name` 28 | 0. Make your change, add tests, and make sure the tests still pass 29 | 0. Push to your branch and [submit a pull request][pr] 30 | 0. Wait for your pull request to be reviewed and merged! 31 | 32 | Here are a few things you can do that will increase the likelihood of your pull request being accepted: 33 | 34 | - Follow the [style guide][style]. 35 | - Write tests. 36 | - Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests. 37 | - Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). 38 | 39 | ## Resources 40 | 41 | - [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/) 42 | - [Using Pull Requests](https://help.github.com/articles/using-pull-requests/) 43 | - [GitHub Help](https://help.github.com) 44 | -------------------------------------------------------------------------------- /Dummy_Database.md: -------------------------------------------------------------------------------- 1 | ### Copy and Paste the following MYSQL commands to make a dummy database for this Project : 2 | 3 | 4 | create database if not exists onlinebookstore; 5 | 6 | use onlinebookstore; 7 | 8 | create table if not exists books(barcode varchar(100) primary key, name varchar(100), author varchar(100), price int, quantity int); 9 | 10 | create table if not exists users(username varchar(100) primary key,password varchar(100), firstname varchar(100),lastname varchar(100),address text, phone varchar(100),mailid varchar(100),usertype int); 11 | 12 | insert into books values('9780134190500', 'Data Structures Through C', 'G.S. Baluja', 525, 20); 13 | 14 | insert into books values('9780134190563','The Go Programming Language','Alan A. A. Donovan and Brian W. Kernighan',400,8); 15 | 16 | insert into books values('9780133053036','C++ Primer','Stanley Lippman and Josée Lajoie and Barbara Moo',976,13); 17 | 18 | insert into books values('9781718500457','The Rust Programming Language','Steve Klabnik and Carol Nichols',560,12); 19 | 20 | insert into books values('9781491910740','Head First Java','Kathy Sierra and Bert Bates and Trisha Gee',754,23); 21 | 22 | insert into books values('9781492056300','Fluent Python','Luciano Ramalho',1014,5); 23 | 24 | insert into books values('9781720043997','The Road to Learn React','Robin Wieruch',239,18); 25 | 26 | insert into books values('9780132350884','Clean Code: A Handbook of Agile Software Craftsmanship','Robert C Martin',288,3); 27 | 28 | insert into books values('9780132181273','Domain-Driven Design','Eric Evans',560,28); 29 | 30 | insert into books values('9780132181785', 'Let us C', 'Yashavant Kanetkar', 329, 15); 31 | 32 | insert into books values('9781951204006','A Programmers Guide to Computer Science','William Springer',188,4); 33 | 34 | insert into books values('9780316204552','The Soul of a New Machine','Tracy Kidder',293,30); 35 | 36 | insert into books values('9780132778046','Effective Java','Joshua Bloch',368,21); 37 | 38 | insert into books values('9781484255995','Practical Rust Projects','Shing Lyu',257,15); 39 | 40 | insert into books values('9781484255996','Agni Veena','Kazi Nasrul Islam',259,25); 41 | 42 | insert into users values('demo','demo','Demo','User','Demo Home','42502216225','demo@gmail.com',2); 43 | 44 | insert into users values('Admin','Admin','Mr.','Admin','Haldia WB','9584552224521','admin@gmail.com',1); 45 | 46 | insert into users values('shashi','shashi','Shashi','Raj','Bihar','1236547089','shashi@gmail.com',2); 47 | 48 | commit; 49 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent any 3 | stages { 4 | stage("git_checkout") { 5 | steps { 6 | echo "cloning repository" 7 | echo "repo cloned successfully" 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OnlineBookStore 2 | - A Java Web Developement Project 3 | - **Youtube VIDEO** for step by step Local Setup Guide : https://youtu.be/mLFPodZO8Iw 4 | - **Youtube VIDEO** for local setup of tender management project: https://www.youtube.com/watch?v=7CE3aY4e644 5 | 6 | - User Login Credentials: (shashi/shashi) 7 | - Admin Login Credentials: (Admin/Admin) 8 |
9 | 10 | ### About 11 | 12 | A user-friendly Online Bookstore project in which users can log in or register, view the available books, select books along with their quantity, and buy them. Users can also get payment receipts after successful payment. The project can also be used by the administrator, who can add new books, remove books, increase and decrease the quantity of books, change the price of the books as well as maintain the selling history of books. 13 | 14 | ![onlinebookstore](https://user-images.githubusercontent.com/34605595/137615096-8447d32d-bddc-4f13-a8ed-3c0f4dd5e04e.png) 15 | 16 | **This Website is built for following purpose:-** 17 | - For Selling books online. 18 | - Maintaining books selling history. 19 | - Adding and managing books. 20 | - User Friendly. 21 | - For Implementation of Http Servlets in Java. 22 | - This is a Mini-project developed using Java, Jdbc, And Servlets. 23 | 24 | **Admin Have Following Access for this online store site:-** 25 | - Add New Books. 26 | - View Books Available. 27 | - Remove Books. 28 | - Increase Books Amount. 29 | 30 | **Users Have Following Access for this online store site:-** 31 | - Create New Account or Register. 32 | - Login. 33 | - View Available Books. 34 | - Select Books to Buy. 35 | - Select Books Quantity. 36 | - Buy Books. 37 | - Get Payment Receipt. 38 | 39 | ### Technologies used:- 40 | 1. Front-End Development: 41 | - HTML 42 | - CSS 43 | - Javascript 44 | - BootStrap 45 | 46 | 2. Back-End Development: 47 | - Java [JDK 8+] 48 | - JDBC 49 | - Servlet 50 | 51 | 3. Database: 52 | - MySql 53 | 54 | ### ================ Software And Tools Required ================ 55 | - : Git [https://www.youtube.com/watch?v=gv7VPQ4LZ7g] 56 | - : Java JDK 8+ [https://www.youtube.com/watch?v=O9PWH9SeTTE] 57 | - : Eclipse EE (Enterprise Edition) [https://www.youtube.com/watch?v=8aDsEV7txXE] 58 | - : Apache Maven [https://www.youtube.com/watch?v=jd2zx3dLjuw] 59 | - : Tomcat v8.0+ [https://youtu.be/mLFPodZO8Iw?t=903] 60 | - : MySQL Server [https://www.youtube.com/watch?v=Ydh5jYA6Frs] 61 | - : MySQL Workbench (optional) [https://www.youtube.com/watch?v=t79oCeTXHwg] 62 | 63 | ### ================= Dummy Database Initialization ================= 64 | 65 | STEP 1: Open MySQL Command Prompt or MySQL Workbench 66 | 67 | STEP 2: Login to the administrator user as : ```mysql -u -p``` (Enter Password if asked) 68 | 69 | STEP 3: Copy paste the following MySql Commands- 70 | ```MySQL 71 | create database if not exists onlinebookstore; 72 | 73 | use onlinebookstore; 74 | 75 | create table if not exists books(barcode varchar(100) primary key, name varchar(100), author varchar(100), price int, quantity int); 76 | 77 | create table if not exists users(username varchar(100) primary key,password varchar(100), firstname varchar(100), 78 | lastname varchar(100),address text, phone varchar(100),mailid varchar(100),usertype int); 79 | 80 | insert into books values('9780134190563','The Go Programming Language','Alan A. A. Donovan and Brian W. Kernighan',400,8); 81 | insert into books values('9780133053036','C++ Primer','Stanley Lippman and Josée Lajoie and Barbara Moo',976,13); 82 | insert into books values('9781718500457','The Rust Programming Language','Steve Klabnik and Carol Nichols',560,12); 83 | insert into books values('9781491910740','Head First Java','Kathy Sierra and Bert Bates and Trisha Gee',754,23); 84 | insert into books values('9781492056300','Fluent Python','Luciano Ramalho',1014,5); 85 | insert into books values('9781720043997','The Road to Learn React','Robin Wieruch',239,18); 86 | insert into books values('9780132350884','Clean Code: A Handbook of Agile Software Craftsmanship','Robert C Martin',288,3); 87 | insert into books values('9780132181273','Domain-Driven Design','Eric Evans',560,28); 88 | insert into books values('9781951204006','A Programmers Guide to Computer Science','William Springer',188,4); 89 | insert into books values('9780316204552','The Soul of a New Machine','Tracy Kidder',293,30); 90 | insert into books values('9780132778046','Effective Java','Joshua Bloch',368,21); 91 | insert into books values('9781484255995','Practical Rust Projects','Shing Lyu',257,15); 92 | insert into users values('demo','demo','Demo','User','Demo Home','42502216225','demo@gmail.com',2); 93 | insert into users values('Admin','Admin','Mr.','Admin','Haldia WB','9584552224521','admin@gmail.com',1); 94 | insert into users values('shashi','shashi','Shashi','Raj','Bihar','1236547089','shashi@gmail.com',2); 95 | 96 | commit; 97 | 98 | ``` 99 | 100 | ### ========== Importing and Running The Project Through Eclipse EE ========== 101 | 102 | Step 0: Open Eclipse Enterprise Edition. [Install, if not already installed.] 103 | 104 | Step 1: Click On File > Import > Git > Projects From Git > Clone Uri > Paste The Repository Url as: ```https://github.com/shashirajraja/onlinebookstore.git```> Select master Branch > Next > Next > Finish. 105 | 106 | Step 2. a: Go inside ```src/main/resources > application.properties``` and update the value of database details as per your usage, like db.driver, db.host, db.username and db.password according to your installed mysql/postgresql admin user credentials. 107 | 108 | Step 2.b: Right Click on Project > Run as > Maven Build > In the goals field enter "clean install" > apply > run 109 | 110 | Step 2.c: Right Click On Project > Build Path > Configure Build Path > Libraries > Remove and Update Any Libraries if Red Mark Exists > Finish. 111 | 112 | Step 3: [Only If Tomcat Server is not configured in Eclipse] : Right Click On Project > Run As > Run On Server > Select Tomcat V8.0 > (Select Tomcat V8.0 Installation Location If Asked) Next > Add onlinebookstore > Finish. 113 | 114 | Step 4: In The Server Tab > Double Click On Tomcat Server > Ports > Change The Port Number For Http/1.1 To 8083 > Close And Save. 115 | 116 | Step 5: Right Click On Project > Run As > Run On Server > Select Tomcat v8.0 > Next > Add All> Done. 117 | 118 | Step 6: Check Running The Site At http://localhost:8083/onlinebookstore/ 119 | 120 | Step 7: Default Username And Password For Admin Is "Admin" And "Admin" 121 | 122 | Step 8: The default Username And Password For User Is "shashi" And "shashi" 123 | 124 | ## FAQ 125 | **Question:1** Unable to Connect to Database? 126 | 127 | **Answer:** Please check you have installed the mysql correctly and have updated the correct db details in application.properties file. Also you can try doing maven clean install and force update the project and restart. 128 |
129 | 130 | Note:- Considering this as a Sample Project, we have not much considered of web security. 131 | #### Some Screenshots for the project: 132 | image 133 | image 134 | image 135 | image 136 | image 137 | 138 | 139 | #### "Suggestions and project improvement ideas are welcomed!" 140 | 141 | Thanks a lot,
142 | Project Leader
143 | Shashi Raj 144 | -------------------------------------------------------------------------------- /WebContent/Animated buttons: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Gradient Color Effect | CodingNepal 5 | 6 | 7 | 225 | ANIMATED BUTTONS 226 | 227 |

228 |
229 | 230 | 231 | 232 |

233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 |
241 | 242 | 243 | 244 | "BUTTON 5" 245 | 246 | 247 | -------------------------------------------------------------------------------- /WebContent/CustomerHome.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Book Store 5 | 7 | 9 | 11 | 12 | 14 | 15 | 16 | 18 | 22 | 26 | 29 | 30 | 31 |
32 | 63 |
64 | 65 | 66 | 67 | 69 | 71 | 74 | 75 | -------------------------------------------------------------------------------- /WebContent/CustomerLogin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Book Store 5 | 7 | 9 | 11 | 12 | 14 | 15 | 69 | 70 | 71 |
72 | 95 |
96 | 97 |
98 |

Welcome to Online Book Store

99 |
100 | 101 |
103 | 104 | 105 | 106 | 107 | 108 | 111 | 112 | 113 | 130 | 131 |
Customer LOGIN
Are you Seller?, Click 110 | Here to Login as Admin



118 |
119 | 120 |
121 |
46749
122 |
123 |
126 |
127 |

128 |
132 |
133 | 134 | 135 | 136 | 138 | 140 | 199 | 200 | 201 | -------------------------------------------------------------------------------- /WebContent/CustomerRegister.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Book Store 5 | 7 | 9 | 11 | 12 | 13 | 14 | 23 | 24 | 25 |
26 | 44 |
45 |
46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 97 | 98 | 99 |
Enter the Registration Details
55 | 60 | 61 | 63 |
64 | 65 | 68 |
69 | 70 | 73 |
74 | 75 | 78 |
79 | 80 | 82 |
83 | 84 | 87 |
88 | 90 | 94 |
95 | 96 |
100 |
101 | 102 | 103 | 104 | 105 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /WebContent/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /WebContent/Photo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shashirajraja/onlinebookstore/58c7929bff69672bb1c4f24abc53b887dbc91ec1/WebContent/Photo.jpg -------------------------------------------------------------------------------- /WebContent/SellerHome.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Book Store 5 | 7 | 9 | 11 | 12 | 14 | 15 | 16 | 18 | 22 | 26 | 29 | 30 | 31 |
32 | 66 |
67 | 68 | 69 | 70 | 72 | 74 | 77 | 78 | -------------------------------------------------------------------------------- /WebContent/SellerLogin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Book Store 5 | 7 | 9 | 11 | 12 | 13 | 14 | 39 | 40 | 41 |
42 | 60 |
61 | 62 |
63 |

Welcome to Online Book Store

64 |
65 | 66 |
67 | 68 | 69 | 70 | 71 | 72 | 73 | 86 | 87 |
Admin LOGIN
Not an Admin?, Click Here to Login as Customer
74 | 75 |
77 |
78 | 79 | 80 |

83 | 85 |
88 |
89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /WebContent/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | SellerLoginServlet 7 | servlets.SellerLoginServlet 8 | 9 | 10 | SellerLoginServlet 11 | /adminlog 12 | 13 | 14 | StoreBookServlet 15 | servlets.StoreBookServlet 16 | 17 | 18 | StoreBookServlet 19 | /storebooks 20 | 21 | 22 | UpdateBookServlet 23 | servlets.UpdateBookServlet 24 | 25 | 26 | UpdateBookServlet 27 | /updatebook 28 | 29 | 30 | CustomerLoginServlet 31 | servlets.CustomerLoginServlet 32 | 33 | 34 | CustomerLoginServlet 35 | /userlog 36 | 37 | 38 | AboutServlet 39 | servlets.AboutServlet 40 | 41 | 42 | AboutServlet 43 | /about 44 | 45 | 46 | LogoutServlet 47 | servlets.LogoutServlet 48 | 49 | 50 | LogoutServlet 51 | /logout 52 | 53 | 54 | CustomerRegisterServlet 55 | servlets.CustomerRegisterServlet 56 | 57 | 58 | CustomerRegisterServlet 59 | /userreg 60 | 61 | 62 | RemoveBookServlet 63 | servlets.RemoveBookServlet 64 | 65 | 66 | RemoveBookServlet 67 | /removebook 68 | 69 | 70 | AddBookServlet 71 | servlets.AddBookServlet 72 | 73 | 74 | AddBookServlet 75 | /addbook 76 | 77 | 78 | ViewBookServlet 79 | servlets.ViewBookServlet 80 | 81 | 82 | ViewBookServlet 83 | /viewbook 84 | 85 | 86 | CartServlet 87 | servlets.CartServlet 88 | 89 | 90 | CartServlet 91 | /cart 92 | 93 | 94 | BuyBooksServlet 95 | servlets.BuyBooksServlet 96 | 97 | 98 | BuyBooksServlet 99 | /buybook 100 | 101 | 102 | ReceiptServlet 103 | servlets.ReceiptServlet 104 | 105 | 106 | ReceiptServlet 107 | /buys 108 | 109 | 110 | CheckoutServlet 111 | servlets.CheckoutServlet 112 | 113 | 114 | CheckoutServlet 115 | /checkout 116 | 117 | 118 | ProcessPaymentServlet 119 | servlets.ProcessPaymentServlet 120 | 121 | 122 | ProcessPaymentServlet 123 | /pay 124 | 125 | 126 | 127 | 128 | ErrorHandlerServlet 129 | servlets.ErrorHandlerServlet 130 | 131 | 132 | ErrorHandlerServlet 133 | /error 134 | 135 | 136 | 137 | 404 138 | /error 139 | 140 | 141 | 405 142 | /error 143 | 144 | 145 | 146 | 147 | 148 | javax.servlet.ServletException 149 | 150 | /error 151 | 152 | 153 | 154 | java.lang.Throwable 155 | /error 156 | 157 | 158 | 159 | 160 | index.html 161 | 162 | -------------------------------------------------------------------------------- /WebContent/favicons/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shashirajraja/onlinebookstore/58c7929bff69672bb1c4f24abc53b887dbc91ec1/WebContent/favicons/android-chrome-192x192.png -------------------------------------------------------------------------------- /WebContent/favicons/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shashirajraja/onlinebookstore/58c7929bff69672bb1c4f24abc53b887dbc91ec1/WebContent/favicons/android-chrome-512x512.png -------------------------------------------------------------------------------- /WebContent/favicons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shashirajraja/onlinebookstore/58c7929bff69672bb1c4f24abc53b887dbc91ec1/WebContent/favicons/apple-touch-icon.png -------------------------------------------------------------------------------- /WebContent/favicons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shashirajraja/onlinebookstore/58c7929bff69672bb1c4f24abc53b887dbc91ec1/WebContent/favicons/favicon-16x16.png -------------------------------------------------------------------------------- /WebContent/favicons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shashirajraja/onlinebookstore/58c7929bff69672bb1c4f24abc53b887dbc91ec1/WebContent/favicons/favicon-32x32.png -------------------------------------------------------------------------------- /WebContent/favicons/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shashirajraja/onlinebookstore/58c7929bff69672bb1c4f24abc53b887dbc91ec1/WebContent/favicons/favicon.ico -------------------------------------------------------------------------------- /WebContent/favicons/site.webmanifest: -------------------------------------------------------------------------------- 1 | {"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} -------------------------------------------------------------------------------- /WebContent/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Book Store 5 | 7 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 36 |
37 |
38 |

Welcome to Online
Book Store

39 |
40 | 41 | 42 | 43 | 44 |
Happy Learning!!
Welcome to our book store!
45 | 46 | 47 | 48 | 49 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /WebContent/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shashirajraja/onlinebookstore/58c7929bff69672bb1c4f24abc53b887dbc91ec1/WebContent/loader.gif -------------------------------------------------------------------------------- /WebContent/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Book Store 5 | 7 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 36 |
37 |

Welcome to Online Book Store

38 |
39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |
Login or SignUp Below
Login As Admin
Login As Customer
New user ! Register Here
54 | 55 | 56 | 57 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /WebContent/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shashirajraja/onlinebookstore/58c7929bff69672bb1c4f24abc53b887dbc91ec1/WebContent/logo.png -------------------------------------------------------------------------------- /WebContent/payment.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Book Store 5 | 7 | 9 | 11 | 12 | 14 | 15 | 16 | 18 | 22 | 23 | 27 | 28 | 113 | 114 | 115 |
116 | 143 |
144 | 145 | 147 | 149 |
150 |
Cart Checkout
151 |
152 |
153 |
154 |
155 |
156 |
157 |

Billing Address

158 | 159 | 164 | 168 | 169 |
170 |
171 | 173 |
174 |
175 | 177 |
178 |
179 |
180 | 181 |
182 |

Payment

183 | 184 |
185 | 189 |
190 | 192 | 197 | 198 |
199 |
200 | 202 |
203 |
204 | 206 |
207 |
208 |
209 | 210 |
211 | 214 | 215 | 216 | -------------------------------------------------------------------------------- /WebContent/styles.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | } 4 | 5 | body { 6 | background-image: url("Photo.jpg"); 7 | font-family: 'Segoe UI','Open Sans', 'Helvetica Neue', sans-serif; 8 | } 9 | 10 | #topmid { 11 | border: 0px solid black; 12 | color: #FFFFFF; 13 | text-align: center; 14 | font-weight: bold; 15 | margin: auto; 16 | font-style: oblique; 17 | font-size: 25px; 18 | text-shadow: 2px 2px #ff0000; 19 | } 20 | 21 | .tab { 22 | font-weight: bold; 23 | margin: auto; 24 | width:35%; 25 | text-align:center; 26 | } 27 | 28 | .tab tr { 29 | border: 1px black hidden; 30 | border-radius: 10px; 31 | background-color: #FFE5CC; 32 | font-size: 22px; 33 | float:left; 34 | padding-left:17%; 35 | padding-bottom:5px; 36 | padding-top:2px; 37 | margin-bottom:10px; 38 | width:100%; 39 | } 40 | 41 | a:hover { 42 | color: red; 43 | } 44 | 45 | a:link { 46 | color: black; 47 | text-decoration: none; 48 | } 49 | 50 | header nav li :hover{ 51 | border-bottom: 2px #ffff80 solid; 52 | border-radius: 10px; 53 | color: #ffff80; 54 | padding-bottom:2px; 55 | } 56 | 57 | header nav li{ 58 | display: table; 59 | height: 80%; 60 | float: left; 61 | margin-right: 20px; 62 | padding-left: 10px; 63 | 64 | } 65 | 66 | header nav a{ 67 | color: #ffffff; 68 | } 69 | 70 | header nav li a.active { 71 | border-bottom: 2px #ffff80 solid; 72 | border-radius: 10px; 73 | color: #ffff80; 74 | padding-bottom:2px; 75 | } 76 | 77 | 78 | .holds-the-iframe { 79 | background: url(loader.gif) center center no-repeat; 80 | } -------------------------------------------------------------------------------- /appspec.yaml: -------------------------------------------------------------------------------- 1 | version: 0.0 2 | os: linux 3 | files: 4 | - source: /output/books.war 5 | destination: /opt/tomcat8/webapps 6 | hooks: 7 | BeforeInstall: 8 | - location: scripts/start_server.sh 9 | timeout: 300 10 | runas: root 11 | ApplicationStop: 12 | - location: scripts/stop_server.sh 13 | timeout: 300 14 | runas: root 15 | -------------------------------------------------------------------------------- /buildspec.yaml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | phases: 4 | install: 5 | runtime-versions: 6 | java: corretto8 7 | commands: 8 | - apt update -y 9 | build: 10 | commands: 11 | - mvn clean package 12 | - mkdir output 13 | - cp target/*.war output/books.war 14 | artifacts: 15 | files: 16 | - 'output/*.war' 17 | - appspec.yaml 18 | - scripts/* 19 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | onlinebookstore 6 | onlinebookstore 7 | 0.0.1-SNAPSHOT 8 | war 9 | 10 | src/main/java 11 | onlinebookstore 12 | 13 | 14 | org.apache.maven.plugins 15 | maven-dependency-plugin 16 | 2.3 17 | 18 | 19 | package 20 | 21 | copy 22 | 23 | 24 | 25 | 26 | com.github.jsimone 27 | webapp-runner 28 | 8.0.30.2 29 | webapp-runner.jar 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | maven-compiler-plugin 38 | 3.11.0 39 | 40 | 1.8 41 | 1.8 42 | 43 | 44 | 45 | maven-war-plugin 46 | 3.2.1 47 | 48 | WebContent 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.postgresql 57 | postgresql 58 | 42.3.7 59 | 60 | 61 | 62 | 63 | mysql 64 | mysql-connector-java 65 | 8.0.28 66 | 67 | 68 | 69 | 70 | javax.servlet 71 | javax.servlet-api 72 | 3.1.0 73 | 74 | 75 | -------------------------------------------------------------------------------- /scripts/start_server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /opt/tomcat8/bin 3 | ./startup.sh 4 | -------------------------------------------------------------------------------- /scripts/stop_server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /opt/tomcat8/bin 3 | ./shutdown.sh 4 | -------------------------------------------------------------------------------- /setup/CreateDatastore.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE if not exists onlinebookstore; 2 | 3 | \c onlinebookstore 4 | 5 | CREATE TABLE if not exists books 6 | ( 7 | barcode VARCHAR(100) PRIMARY KEY, 8 | name TEXT NOT NULL, 9 | author VARCHAR(100) NOT NULL, 10 | price INT, 11 | quantity REAL 12 | ); 13 | 14 | CREATE TABLE if not exists users 15 | ( 16 | username VARCHAR(100) PRIMARY KEY, 17 | password VARCHAR(100) NOT NULL, 18 | firstname VARCHAR(100) NOT NULL, 19 | lastname VARCHAR(100) NOT NULL, 20 | address TEXT NOT NULL, 21 | phone VARCHAR(100) NOT NULL, 22 | mailid VARCHAR(100) NOT NULL, 23 | usertype INT 24 | ); -------------------------------------------------------------------------------- /src/main/java/com/bittercode/constant/BookStoreConstants.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.constant; 2 | 3 | public interface BookStoreConstants { 4 | public static String CONTENT_TYPE_TEXT_HTML = "text/html"; 5 | 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/constant/ResponseCode.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.constant; 2 | 3 | import java.util.Arrays; 4 | import java.util.Optional; 5 | 6 | public enum ResponseCode { 7 | 8 | SUCCESS(200, "OK"), 9 | FAILURE(422, "Unprocessible Entity, Failed to Process"), 10 | PAGE_NOT_FOUND(404, "The Page You are Searching For is Not available"), 11 | ACCESS_DENIED(403, "Please Login First to continue"), 12 | BAD_REQUEST(400, "Bad Request, Please Try Again"), 13 | INTERNAL_SERVER_ERROR(500, "Internal Server Error, Try Again!!"), 14 | DATABASE_CONNECTION_FAILURE(406, 15 | "Unable to Connect to DB, Please Check your db credentials in application.properties"), 16 | METHOD_NOT_ALLOWED(405, "Requested HTTP method is not supported by this URL"), 17 | 18 | ; 19 | 20 | private final String message; 21 | private final int code; 22 | 23 | ResponseCode(int code, String message) { 24 | this.message = message; 25 | this.code = code; 26 | } 27 | 28 | public String getMessage() { 29 | return message; 30 | } 31 | 32 | public int getCode() { 33 | return code; 34 | } 35 | 36 | // Reverse lookup methods 37 | public static Optional getMessageByStatusCode(int statusCode) { 38 | return Arrays.stream(ResponseCode.values()) 39 | .filter(error -> error.getCode() == statusCode) 40 | .findFirst(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/constant/db/BooksDBConstants.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.constant.db; 2 | 3 | public interface BooksDBConstants { 4 | 5 | public static String TABLE_BOOK = "books"; 6 | 7 | public static String COLUMN_NAME = "name"; 8 | public static String COLUMN_BARCODE = "barcode"; 9 | public static String COLUMN_AUTHOR = "author"; 10 | public static String COLUMN_PRICE = "price"; 11 | public static String COLUMN_QUANTITY = "quantity"; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/constant/db/UsersDBConstants.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.constant.db; 2 | 3 | public interface UsersDBConstants { 4 | 5 | public static String TABLE_USERS = "users"; 6 | 7 | public static String COLUMN_USERNAME = "username"; 8 | public static String COLUMN_PASSWORD = "password"; 9 | public static String COLUMN_FIRSTNAME = "firstname"; 10 | public static String COLUMN_LASTNAME = "lastname"; 11 | public static String COLUMN_ADDRESS = "address"; 12 | public static String COLUMN_PHONE = "phone"; 13 | public static String COLUMN_MAILID = "mailid"; 14 | public static String COLUMN_USERTYPE = "usertype"; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/model/Address.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Address implements Serializable { 6 | 7 | private String addressLine1; 8 | private String addressLine2; 9 | private String city; 10 | private String state; 11 | private String country; 12 | private long pinCode; 13 | private String phone; 14 | 15 | public String getAddressLine1() { 16 | return addressLine1; 17 | } 18 | 19 | public void setAddressLine1(String addressLine1) { 20 | this.addressLine1 = addressLine1; 21 | } 22 | 23 | public String getAddressLine2() { 24 | return addressLine2; 25 | } 26 | 27 | public void setAddressLine2(String addressLine2) { 28 | this.addressLine2 = addressLine2; 29 | } 30 | 31 | public String getCity() { 32 | return city; 33 | } 34 | 35 | public void setCity(String city) { 36 | this.city = city; 37 | } 38 | 39 | public String getState() { 40 | return state; 41 | } 42 | 43 | public void setState(String state) { 44 | this.state = state; 45 | } 46 | 47 | public String getCountry() { 48 | return country; 49 | } 50 | 51 | public void setCountry(String country) { 52 | this.country = country; 53 | } 54 | 55 | public long getPinCode() { 56 | return pinCode; 57 | } 58 | 59 | public void setPinCode(long pinCode) { 60 | this.pinCode = pinCode; 61 | } 62 | 63 | public String getPhone() { 64 | return phone; 65 | } 66 | 67 | public void setPhone(String phone) { 68 | this.phone = phone; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/model/Book.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Book implements Serializable { 6 | 7 | private String barcode; 8 | private String name; 9 | private String author; 10 | private double price; 11 | private int quantity; 12 | 13 | public Book(String barcode, String name, String author, double price, int quantity) { 14 | this.barcode = barcode; 15 | this.name = name; 16 | this.author = author; 17 | this.setPrice(price); 18 | this.quantity = quantity; 19 | } 20 | 21 | public Book() { 22 | super(); 23 | } 24 | 25 | public String getBarcode() { 26 | return barcode; 27 | } 28 | 29 | public void setBarcode(String barcode) { 30 | this.barcode = barcode; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | public String getAuthor() { 42 | return author; 43 | } 44 | 45 | public void setAuthor(String author) { 46 | this.author = author; 47 | } 48 | 49 | public int getQuantity() { 50 | return quantity; 51 | } 52 | 53 | public void setQuantity(int quantity) { 54 | this.quantity = quantity; 55 | } 56 | 57 | public double getPrice() { 58 | return price; 59 | } 60 | 61 | public void setPrice(double price) { 62 | this.price = price; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/model/Cart.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Cart implements Serializable { 6 | 7 | private Book book; 8 | private int quantity; 9 | 10 | public Cart(Book book, int quantity) { 11 | this.book = book; 12 | this.quantity = quantity; 13 | } 14 | 15 | public Book getBook() { 16 | return book; 17 | } 18 | 19 | public void setBook(Book book) { 20 | this.book = book; 21 | } 22 | 23 | public int getQuantity() { 24 | return quantity; 25 | } 26 | 27 | public void setQuantity(int quantity) { 28 | this.quantity = quantity; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/model/StoreException.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.model; 2 | 3 | import java.io.IOException; 4 | 5 | import com.bittercode.constant.ResponseCode; 6 | 7 | public class StoreException extends IOException { 8 | 9 | private String errorCode; 10 | private String errorMessage; 11 | private int statusCode; 12 | 13 | public StoreException(String errorMessage) { 14 | super(errorMessage); 15 | this.errorCode = "BAD_REQUEST"; 16 | this.setStatusCode(400); 17 | this.errorMessage = errorMessage; 18 | } 19 | 20 | public StoreException(ResponseCode errorCodes) { 21 | super(errorCodes.getMessage()); 22 | this.statusCode = errorCodes.getCode(); 23 | this.errorMessage = errorCodes.getMessage(); 24 | this.setErrorCode(errorCodes.name()); 25 | } 26 | 27 | public StoreException(String errroCode, String errorMessage) { 28 | super(errorMessage); 29 | this.errorCode = errroCode; 30 | this.errorMessage = errorMessage; 31 | this.statusCode = 422; 32 | } 33 | 34 | public StoreException(int statusCode, String errorCode, String errorMessage) { 35 | super(errorMessage); 36 | this.statusCode = statusCode; 37 | this.errorCode = errorCode; 38 | this.errorMessage = errorMessage; 39 | } 40 | 41 | public String getErrorCode() { 42 | return errorCode; 43 | } 44 | 45 | public void setErrorCode(String errorCode) { 46 | this.errorCode = errorCode; 47 | } 48 | 49 | public String getErrorMessage() { 50 | return errorMessage; 51 | } 52 | 53 | public void setErrorMessage(String errorMessage) { 54 | this.errorMessage = errorMessage; 55 | } 56 | 57 | public int getStatusCode() { 58 | return statusCode; 59 | } 60 | 61 | public void setStatusCode(int statusCode) { 62 | this.statusCode = statusCode; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/model/User.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.model; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | public class User implements Serializable { 7 | 8 | private String emailId; 9 | private String password; 10 | private String firstName; 11 | private String lastName; 12 | private Long phone; 13 | private String address; 14 | private List roles; 15 | 16 | public String getEmailId() { 17 | return emailId; 18 | } 19 | 20 | public void setEmailId(String emailId) { 21 | this.emailId = emailId; 22 | } 23 | 24 | public String getPassword() { 25 | return password; 26 | } 27 | 28 | public void setPassword(String password) { 29 | this.password = password; 30 | } 31 | 32 | public String getFirstName() { 33 | return firstName; 34 | } 35 | 36 | public void setFirstName(String firstName) { 37 | this.firstName = firstName; 38 | } 39 | 40 | public String getLastName() { 41 | return lastName; 42 | } 43 | 44 | public void setLastName(String lastName) { 45 | this.lastName = lastName; 46 | } 47 | 48 | public Long getPhone() { 49 | return phone; 50 | } 51 | 52 | public void setPhone(Long phone) { 53 | this.phone = phone; 54 | } 55 | 56 | public String getAddress() { 57 | return address; 58 | } 59 | 60 | public void setAddress(String address) { 61 | this.address = address; 62 | } 63 | 64 | public List getRoles() { 65 | return roles; 66 | } 67 | 68 | public void setRoles(List roles) { 69 | this.roles = roles; 70 | } 71 | 72 | // public static User retrieveFromHttpServletRequest(HttpServletRequest req) { 73 | // User user = new User(); 74 | // String pWord = req.getParameter(UsersDBConstants.COLUMN_PASSWORD); 75 | // String fName = req.getParameter(UsersDBConstants.COLUMN_FIRSTNAME); 76 | // String lName = req.getParameter(UsersDBConstants.COLUMN_LASTNAME); 77 | // String addr = req.getParameter(UsersDBConstants.COLUMN_ADDRESS); 78 | // String phNo = req.getParameter(UsersDBConstants.COLUMN_PHONE); 79 | // String mailId = req.getParameter(UsersDBConstants.COLUMN_MAILID); 80 | // user.setEmailId(mailId); 81 | // user.setFirstName(fName); 82 | // user.setLastName(lName); 83 | // user.setPassword(pWord); 84 | // user.setPhone(Long.parseLong(phNo)); 85 | // user.setAddress(addr); 86 | // return user; 87 | // } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/model/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.model; 2 | 3 | public enum UserRole { 4 | CUSTOMER, SELLER 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/model/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | /** 5 | * @author shashirajraja 6 | * 7 | */ 8 | package com.bittercode.model; -------------------------------------------------------------------------------- /src/main/java/com/bittercode/service/BookService.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.service; 2 | 3 | import java.util.List; 4 | 5 | import com.bittercode.model.Book; 6 | import com.bittercode.model.StoreException; 7 | 8 | public interface BookService { 9 | 10 | public Book getBookById(String bookId) throws StoreException; 11 | 12 | public List getAllBooks() throws StoreException; 13 | 14 | public List getBooksByCommaSeperatedBookIds(String commaSeperatedBookIds) throws StoreException; 15 | 16 | public String deleteBookById(String bookId) throws StoreException; 17 | 18 | public String addBook(Book book) throws StoreException; 19 | 20 | public String updateBookQtyById(String bookId, int quantity) throws StoreException; 21 | 22 | public String updateBook(Book book) throws StoreException; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.service; 2 | 3 | import javax.servlet.http.HttpSession; 4 | 5 | import com.bittercode.model.StoreException; 6 | import com.bittercode.model.User; 7 | import com.bittercode.model.UserRole; 8 | 9 | public interface UserService { 10 | 11 | public User login(UserRole role, String email, String password, HttpSession session) throws StoreException; 12 | 13 | public String register(UserRole role, User user) throws StoreException; 14 | 15 | public boolean isLoggedIn(UserRole role, HttpSession session); 16 | 17 | public boolean logout(HttpSession session); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/service/impl/BookServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.service.impl; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import com.bittercode.constant.ResponseCode; 11 | import com.bittercode.constant.db.BooksDBConstants; 12 | import com.bittercode.model.Book; 13 | import com.bittercode.model.StoreException; 14 | import com.bittercode.service.BookService; 15 | import com.bittercode.util.DBUtil; 16 | 17 | public class BookServiceImpl implements BookService { 18 | 19 | private static final String getAllBooksQuery = "SELECT * FROM " + BooksDBConstants.TABLE_BOOK; 20 | private static final String getBookByIdQuery = "SELECT * FROM " + BooksDBConstants.TABLE_BOOK 21 | + " WHERE " + BooksDBConstants.COLUMN_BARCODE + " = ?"; 22 | 23 | private static final String deleteBookByIdQuery = "DELETE FROM " + BooksDBConstants.TABLE_BOOK + " WHERE " 24 | + BooksDBConstants.COLUMN_BARCODE + "=?"; 25 | 26 | private static final String addBookQuery = "INSERT INTO " + BooksDBConstants.TABLE_BOOK + " VALUES(?,?,?,?,?)"; 27 | 28 | private static final String updateBookQtyByIdQuery = "UPDATE " + BooksDBConstants.TABLE_BOOK + " SET " 29 | + BooksDBConstants.COLUMN_QUANTITY + "=? WHERE " + BooksDBConstants.COLUMN_BARCODE 30 | + "=?"; 31 | 32 | private static final String updateBookByIdQuery = "UPDATE " + BooksDBConstants.TABLE_BOOK + " SET " 33 | + BooksDBConstants.COLUMN_NAME + "=? , " 34 | + BooksDBConstants.COLUMN_AUTHOR + "=?, " 35 | + BooksDBConstants.COLUMN_PRICE + "=?, " 36 | + BooksDBConstants.COLUMN_QUANTITY + "=? " 37 | + " WHERE " + BooksDBConstants.COLUMN_BARCODE 38 | + "=?"; 39 | 40 | @Override 41 | public Book getBookById(String bookId) throws StoreException { 42 | Book book = null; 43 | Connection con = DBUtil.getConnection(); 44 | try { 45 | PreparedStatement ps = con.prepareStatement(getBookByIdQuery); 46 | ps.setString(1, bookId); 47 | ResultSet rs = ps.executeQuery(); 48 | 49 | while (rs.next()) { 50 | String bCode = rs.getString(1); 51 | String bName = rs.getString(2); 52 | String bAuthor = rs.getString(3); 53 | int bPrice = rs.getInt(4); 54 | int bQty = rs.getInt(5); 55 | 56 | book = new Book(bCode, bName, bAuthor, bPrice, bQty); 57 | } 58 | } catch (SQLException e) { 59 | 60 | } 61 | return book; 62 | } 63 | 64 | @Override 65 | public List getAllBooks() throws StoreException { 66 | List books = new ArrayList(); 67 | Connection con = DBUtil.getConnection(); 68 | 69 | try { 70 | PreparedStatement ps = con.prepareStatement(getAllBooksQuery); 71 | ResultSet rs = ps.executeQuery(); 72 | 73 | while (rs.next()) { 74 | String bCode = rs.getString(1); 75 | String bName = rs.getString(2); 76 | String bAuthor = rs.getString(3); 77 | int bPrice = rs.getInt(4); 78 | int bQty = rs.getInt(5); 79 | 80 | Book book = new Book(bCode, bName, bAuthor, bPrice, bQty); 81 | books.add(book); 82 | } 83 | } catch (SQLException e) { 84 | 85 | } 86 | return books; 87 | } 88 | 89 | @Override 90 | public String deleteBookById(String bookId) throws StoreException { 91 | String response = ResponseCode.FAILURE.name(); 92 | Connection con = DBUtil.getConnection(); 93 | try { 94 | PreparedStatement ps = con.prepareStatement(deleteBookByIdQuery); 95 | ps.setString(1, bookId); 96 | int k = ps.executeUpdate(); 97 | if (k == 1) { 98 | response = ResponseCode.SUCCESS.name(); 99 | } 100 | } catch (Exception e) { 101 | response += " : " + e.getMessage(); 102 | e.printStackTrace(); 103 | } 104 | return response; 105 | } 106 | 107 | @Override 108 | public String addBook(Book book) throws StoreException { 109 | String responseCode = ResponseCode.FAILURE.name(); 110 | Connection con = DBUtil.getConnection(); 111 | try { 112 | PreparedStatement ps = con.prepareStatement(addBookQuery); 113 | ps.setString(1, book.getBarcode()); 114 | ps.setString(2, book.getName()); 115 | ps.setString(3, book.getAuthor()); 116 | ps.setDouble(4, book.getPrice()); 117 | ps.setInt(5, book.getQuantity()); 118 | int k = ps.executeUpdate(); 119 | if (k == 1) { 120 | responseCode = ResponseCode.SUCCESS.name(); 121 | } 122 | } catch (Exception e) { 123 | responseCode += " : " + e.getMessage(); 124 | e.printStackTrace(); 125 | } 126 | return responseCode; 127 | } 128 | 129 | @Override 130 | public String updateBookQtyById(String bookId, int quantity) throws StoreException { 131 | String responseCode = ResponseCode.FAILURE.name(); 132 | Connection con = DBUtil.getConnection(); 133 | try { 134 | PreparedStatement ps = con.prepareStatement(updateBookQtyByIdQuery); 135 | ps.setInt(1, quantity); 136 | ps.setString(2, bookId); 137 | ps.executeUpdate(); 138 | responseCode = ResponseCode.SUCCESS.name(); 139 | } catch (Exception e) { 140 | responseCode += " : " + e.getMessage(); 141 | e.printStackTrace(); 142 | } 143 | return responseCode; 144 | } 145 | 146 | @Override 147 | public List getBooksByCommaSeperatedBookIds(String commaSeperatedBookIds) throws StoreException { 148 | List books = new ArrayList(); 149 | Connection con = DBUtil.getConnection(); 150 | try { 151 | String getBooksByCommaSeperatedBookIdsQuery = "SELECT * FROM " + BooksDBConstants.TABLE_BOOK 152 | + " WHERE " + 153 | BooksDBConstants.COLUMN_BARCODE + " IN ( " + commaSeperatedBookIds + " )"; 154 | PreparedStatement ps = con.prepareStatement(getBooksByCommaSeperatedBookIdsQuery); 155 | ResultSet rs = ps.executeQuery(); 156 | 157 | while (rs.next()) { 158 | String bCode = rs.getString(1); 159 | String bName = rs.getString(2); 160 | String bAuthor = rs.getString(3); 161 | int bPrice = rs.getInt(4); 162 | int bQty = rs.getInt(5); 163 | 164 | Book book = new Book(bCode, bName, bAuthor, bPrice, bQty); 165 | books.add(book); 166 | } 167 | } catch (SQLException e) { 168 | 169 | } 170 | return books; 171 | } 172 | 173 | @Override 174 | public String updateBook(Book book) throws StoreException { 175 | String responseCode = ResponseCode.FAILURE.name(); 176 | Connection con = DBUtil.getConnection(); 177 | try { 178 | PreparedStatement ps = con.prepareStatement(updateBookByIdQuery); 179 | ps.setString(1, book.getName()); 180 | ps.setString(2, book.getAuthor()); 181 | ps.setDouble(3, book.getPrice()); 182 | ps.setInt(4, book.getQuantity()); 183 | ps.setString(5, book.getBarcode()); 184 | ps.executeUpdate(); 185 | responseCode = ResponseCode.SUCCESS.name(); 186 | } catch (Exception e) { 187 | responseCode += " : " + e.getMessage(); 188 | e.printStackTrace(); 189 | } 190 | return responseCode; 191 | } 192 | 193 | } 194 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.service.impl; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | 8 | import javax.servlet.http.HttpSession; 9 | 10 | import com.bittercode.constant.ResponseCode; 11 | import com.bittercode.constant.db.UsersDBConstants; 12 | import com.bittercode.model.StoreException; 13 | import com.bittercode.model.User; 14 | import com.bittercode.model.UserRole; 15 | import com.bittercode.service.UserService; 16 | import com.bittercode.util.DBUtil; 17 | 18 | public class UserServiceImpl implements UserService { 19 | 20 | private static final String registerUserQuery = "INSERT INTO " + UsersDBConstants.TABLE_USERS 21 | + " VALUES(?,?,?,?,?,?,?,?)"; 22 | 23 | private static final String loginUserQuery = "SELECT * FROM " + UsersDBConstants.TABLE_USERS + " WHERE " 24 | + UsersDBConstants.COLUMN_USERNAME + "=? AND " + UsersDBConstants.COLUMN_PASSWORD + "=? AND " 25 | + UsersDBConstants.COLUMN_USERTYPE + "=?"; 26 | 27 | @Override 28 | public User login(UserRole role, String email, String password, HttpSession session) throws StoreException { 29 | Connection con = DBUtil.getConnection(); 30 | PreparedStatement ps; 31 | User user = null; 32 | try { 33 | String userType = UserRole.SELLER.equals(role) ? "1" : "2"; 34 | ps = con.prepareStatement(loginUserQuery); 35 | ps.setString(1, email); 36 | ps.setString(2, password); 37 | ps.setString(3, userType); 38 | ResultSet rs = ps.executeQuery(); 39 | if (rs.next()) { 40 | user = new User(); 41 | user.setFirstName(rs.getString("firstName")); 42 | user.setLastName(rs.getString("lastName")); 43 | user.setPhone(rs.getLong("phone")); 44 | user.setEmailId(email); 45 | user.setPassword(password); 46 | session.setAttribute(role.toString(), user.getEmailId()); 47 | } 48 | } catch (SQLException e) { 49 | e.printStackTrace(); 50 | } 51 | return user; 52 | } 53 | 54 | @Override 55 | public boolean isLoggedIn(UserRole role, HttpSession session) { 56 | if (role == null) 57 | role = UserRole.CUSTOMER; 58 | return session.getAttribute(role.toString()) != null; 59 | } 60 | 61 | @Override 62 | public boolean logout(HttpSession session) { 63 | session.removeAttribute(UserRole.CUSTOMER.toString()); 64 | session.removeAttribute(UserRole.SELLER.toString()); 65 | session.invalidate(); 66 | return true; 67 | } 68 | 69 | @Override 70 | public String register(UserRole role, User user) throws StoreException { 71 | String responseMessage = ResponseCode.FAILURE.name(); 72 | Connection con = DBUtil.getConnection(); 73 | try { 74 | PreparedStatement ps = con.prepareStatement(registerUserQuery); 75 | ps.setString(1, user.getEmailId()); 76 | ps.setString(2, user.getPassword()); 77 | ps.setString(3, user.getFirstName()); 78 | ps.setString(4, user.getLastName()); 79 | ps.setString(5, user.getAddress()); 80 | ps.setLong(6, user.getPhone()); 81 | ps.setString(7, user.getEmailId()); 82 | int userType = UserRole.SELLER.equals(role) ? 1 : 2; 83 | ps.setInt(8, userType); 84 | int k = ps.executeUpdate(); 85 | if (k == 1) { 86 | responseMessage = ResponseCode.SUCCESS.name(); 87 | ; 88 | } 89 | } catch (Exception e) { 90 | responseMessage += " : " + e.getMessage(); 91 | if (responseMessage.contains("Duplicate")) 92 | responseMessage = "User already registered with this email !!"; 93 | e.printStackTrace(); 94 | } 95 | return responseMessage; 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/util/DBUtil.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.util; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | 7 | import com.bittercode.constant.ResponseCode; 8 | import com.bittercode.model.StoreException; 9 | 10 | public class DBUtil { 11 | 12 | private static Connection connection; 13 | 14 | static { 15 | 16 | try { 17 | 18 | Class.forName(DatabaseConfig.DRIVER_NAME); 19 | 20 | connection = DriverManager.getConnection(DatabaseConfig.CONNECTION_STRING, DatabaseConfig.DB_USER_NAME, 21 | DatabaseConfig.DB_PASSWORD); 22 | } catch (SQLException | ClassNotFoundException e) { 23 | 24 | e.printStackTrace(); 25 | 26 | } 27 | 28 | }// End of static block 29 | 30 | public static Connection getConnection() throws StoreException { 31 | 32 | if (connection == null) { 33 | throw new StoreException(ResponseCode.DATABASE_CONNECTION_FAILURE); 34 | } 35 | 36 | return connection; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/util/DatabaseConfig.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.util; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.util.Properties; 6 | 7 | class DatabaseConfig { 8 | 9 | static Properties prop = new Properties(); 10 | static { 11 | 12 | ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); 13 | InputStream input = classLoader.getResourceAsStream("application.properties"); 14 | 15 | try { 16 | prop.load(input); 17 | } catch (IOException e) { 18 | e.printStackTrace(); 19 | } 20 | } 21 | 22 | public final static String DRIVER_NAME = prop.getProperty("db.driver"); 23 | public final static String DB_HOST = prop.getProperty("db.host"); 24 | public final static String DB_PORT = prop.getProperty("db.port"); 25 | public final static String DB_NAME = prop.getProperty("db.name"); 26 | public final static String DB_USER_NAME = prop.getProperty("db.username"); 27 | public final static String DB_PASSWORD = prop.getProperty("db.password"); 28 | public final static String CONNECTION_STRING = DB_HOST + ":" + DB_PORT + "/" + DB_NAME; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/bittercode/util/StoreUtil.java: -------------------------------------------------------------------------------- 1 | package com.bittercode.util; 2 | 3 | import java.io.PrintWriter; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpSession; 7 | 8 | import com.bittercode.model.UserRole; 9 | 10 | /* 11 | * Store UTil File To Store Commonly used methods 12 | */ 13 | public class StoreUtil { 14 | 15 | /** 16 | * Check if the User is logged in with the requested role 17 | */ 18 | public static boolean isLoggedIn(UserRole role, HttpSession session) { 19 | 20 | return session.getAttribute(role.toString()) != null; 21 | } 22 | 23 | /** 24 | * Modify the active tab in the page menu bar 25 | */ 26 | public static void setActiveTab(PrintWriter pw, String activeTab) { 27 | 28 | pw.println(""); 30 | pw.println(""); 31 | 32 | } 33 | 34 | /** 35 | * Add/Remove/Update Item in the cart using the session 36 | */ 37 | public static void updateCartItems(HttpServletRequest req) { 38 | String selectedBookId = req.getParameter("selectedBookId"); 39 | HttpSession session = req.getSession(); 40 | if (selectedBookId != null) { // add item to the cart 41 | 42 | // Items will contain comma separated bookIds that needs to be added in the cart 43 | String items = (String) session.getAttribute("items"); 44 | if (req.getParameter("addToCart") != null) { // add to cart 45 | if (items == null || items.length() == 0) 46 | items = selectedBookId; 47 | else if (!items.contains(selectedBookId)) 48 | items = items + "," + selectedBookId; // if items already contains bookId, don't add it 49 | 50 | // set the items in the session to be used later 51 | session.setAttribute("items", items); 52 | 53 | /* 54 | * Quantity of each item in the cart will be stored in the session as: 55 | * Prefixed with qty_ following its bookId 56 | * For example 2 no. of book with id 'myBook' in the cart will be 57 | * added to the session as qty_myBook=2 58 | */ 59 | int itemQty = 0; 60 | if (session.getAttribute("qty_" + selectedBookId) != null) 61 | itemQty = (int) session.getAttribute("qty_" + selectedBookId); 62 | itemQty += 1; 63 | session.setAttribute("qty_" + selectedBookId, itemQty); 64 | } else { // remove from the cart 65 | int itemQty = 0; 66 | if (session.getAttribute("qty_" + selectedBookId) != null) 67 | itemQty = (int) session.getAttribute("qty_" + selectedBookId); 68 | if (itemQty > 1) { 69 | itemQty--; 70 | session.setAttribute("qty_" + selectedBookId, itemQty); 71 | } else { 72 | session.removeAttribute("qty_" + selectedBookId); 73 | items = items.replace(selectedBookId + ",", ""); 74 | items = items.replace("," + selectedBookId, ""); 75 | items = items.replace(selectedBookId, ""); 76 | session.setAttribute("items", items); 77 | } 78 | } 79 | } 80 | 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/servlets/AboutServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.RequestDispatcher; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | import com.bittercode.model.UserRole; 13 | import com.bittercode.util.StoreUtil; 14 | //Http Servlet extended class for showing the about information 15 | public class AboutServlet extends HttpServlet { 16 | 17 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 18 | PrintWriter pw = res.getWriter(); 19 | res.setContentType("text/html"); 20 | //If the store is logged in as customer or seller show about info 21 | if (StoreUtil.isLoggedIn(UserRole.CUSTOMER, req.getSession())) { 22 | RequestDispatcher rd = req.getRequestDispatcher("CustomerHome.html"); 23 | rd.include(req, res); 24 | StoreUtil.setActiveTab(pw, "about"); 25 | pw.println(""); 27 | 28 | } else if (StoreUtil.isLoggedIn(UserRole.SELLER, req.getSession())) { 29 | RequestDispatcher rd = req.getRequestDispatcher("SellerHome.html"); 30 | rd.include(req, res); 31 | StoreUtil.setActiveTab(pw, "about"); 32 | pw.println(""); 34 | 35 | } else { 36 | //If the user is not logged in, ask to login first 37 | //Proceed only if logged in or forword to login page 38 | RequestDispatcher rd = req.getRequestDispatcher("login.html"); 39 | rd.include(req, res); 40 | pw.println("
Please Login First to Continue!!
"); 41 | } 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/servlets/AddBookServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.UUID; 6 | 7 | import javax.servlet.RequestDispatcher; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | import com.bittercode.constant.BookStoreConstants; 14 | import com.bittercode.constant.db.BooksDBConstants; 15 | import com.bittercode.model.Book; 16 | import com.bittercode.model.UserRole; 17 | import com.bittercode.service.BookService; 18 | import com.bittercode.service.impl.BookServiceImpl; 19 | import com.bittercode.util.StoreUtil; 20 | 21 | public class AddBookServlet extends HttpServlet { 22 | BookService bookService = new BookServiceImpl(); 23 | 24 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 25 | PrintWriter pw = res.getWriter(); 26 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 27 | 28 | if (!StoreUtil.isLoggedIn(UserRole.SELLER, req.getSession())) { 29 | RequestDispatcher rd = req.getRequestDispatcher("SellerLogin.html"); 30 | rd.include(req, res); 31 | pw.println("
Please Login First to Continue!!
"); 32 | return; 33 | } 34 | 35 | String bName = req.getParameter(BooksDBConstants.COLUMN_NAME); 36 | RequestDispatcher rd = req.getRequestDispatcher("SellerHome.html"); 37 | rd.include(req, res); 38 | StoreUtil.setActiveTab(pw, "addbook"); 39 | pw.println("
"); 40 | if(bName == null || bName.isBlank()) { 41 | //render the add book form; 42 | showAddBookForm(pw); 43 | return; 44 | } //else process the add book 45 | 46 | 47 | try { 48 | String uniqueID = UUID.randomUUID().toString(); 49 | String bCode = uniqueID; 50 | String bAuthor = req.getParameter(BooksDBConstants.COLUMN_AUTHOR); 51 | double bPrice = Integer.parseInt(req.getParameter(BooksDBConstants.COLUMN_PRICE)); 52 | int bQty = Integer.parseInt(req.getParameter(BooksDBConstants.COLUMN_QUANTITY)); 53 | 54 | Book book = new Book(bCode, bName, bAuthor, bPrice, bQty); 55 | String message = bookService.addBook(book); 56 | if ("SUCCESS".equalsIgnoreCase(message)) { 57 | pw.println( 58 | "
Book Detail Updated Successfully!
Add More Books
"); 59 | } else { 60 | pw.println("
Failed to Add Books! Fill up CareFully
"); 61 | //rd.include(req, res); 62 | } 63 | } catch (Exception e) { 64 | e.printStackTrace(); 65 | pw.println("
Failed to Add Books! Fill up CareFully
"); 66 | } 67 | } 68 | 69 | private static void showAddBookForm(PrintWriter pw) { 70 | String form = "\r\n" 71 | + " \r\n" 72 | + " \r\n" 82 | + " \r\n" 83 | + " \r\n" 86 | + "
\r\n" 73 | + " \r\n" 74 | + " \r\n" 75 | + "
\r\n" 76 | + "
\r\n" 77 | + "
\r\n" 78 | + "
\r\n" 79 | + " \r\n" 80 | + " \r\n" 81 | + "
"; 87 | pw.println(form); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/servlets/BuyBooksServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.List; 6 | 7 | import javax.servlet.RequestDispatcher; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | import com.bittercode.constant.BookStoreConstants; 14 | import com.bittercode.model.Book; 15 | import com.bittercode.model.UserRole; 16 | import com.bittercode.service.BookService; 17 | import com.bittercode.service.impl.BookServiceImpl; 18 | import com.bittercode.util.StoreUtil; 19 | 20 | public class BuyBooksServlet extends HttpServlet { 21 | BookService bookService = new BookServiceImpl(); 22 | 23 | public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 24 | PrintWriter pw = res.getWriter(); 25 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 26 | if (!StoreUtil.isLoggedIn(UserRole.CUSTOMER, req.getSession())) { 27 | RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html"); 28 | rd.include(req, res); 29 | pw.println("
Please Login First to Continue!!
"); 30 | return; 31 | } 32 | try { 33 | List books = bookService.getAllBooks(); 34 | RequestDispatcher rd = req.getRequestDispatcher("CustomerHome.html"); 35 | rd.include(req, res); 36 | StoreUtil.setActiveTab(pw, "cart"); 37 | pw.println("
Books Available In Our Store
"); 38 | pw.println("
"); 39 | pw.println("\r\n" + 40 | " \r\n" + 41 | " \r\n" + 42 | " \r\n" + 43 | " \r\n" + 44 | " \r\n" + 45 | " \r\n" + 46 | " \r\n" + 47 | " \r\n" + 48 | " "); 49 | int i = 0; 50 | for (Book book : books) { 51 | String bCode = book.getBarcode(); 52 | String bName = book.getName(); 53 | String bAuthor = book.getAuthor(); 54 | double bPrice = book.getPrice(); 55 | int bAvl = book.getQuantity(); 56 | i = i + 1; 57 | String n = "checked" + Integer.toString(i); 58 | String q = "qty" + Integer.toString(i); 59 | pw.println("\r\n" + 60 | " "); 65 | pw.println(""); 66 | pw.println(""); 67 | pw.println(""); 68 | pw.println(""); 69 | pw.println(""); 70 | pw.println(""); 71 | 72 | } 73 | pw.println("
BooksCodeNameAuthorPriceAvailQty
\r\n" + 61 | " \r\n" + // Value is 62 | // made equal 63 | // to bcode 64 | " " + bCode + "" + bName + "" + bAuthor + "" + bPrice + "" + bAvl + "
\r\n" + "" + "
" + 74 | "
\r\n" + 75 | "
"); 76 | // pw.println(""); 78 | } catch (Exception e) { 79 | e.printStackTrace(); 80 | } 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/servlets/CartServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import javax.servlet.RequestDispatcher; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.http.HttpServlet; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.servlet.http.HttpServletResponse; 13 | import javax.servlet.http.HttpSession; 14 | 15 | import com.bittercode.constant.BookStoreConstants; 16 | import com.bittercode.model.Book; 17 | import com.bittercode.model.Cart; 18 | import com.bittercode.model.UserRole; 19 | import com.bittercode.service.BookService; 20 | import com.bittercode.service.impl.BookServiceImpl; 21 | import com.bittercode.util.StoreUtil; 22 | 23 | public class CartServlet extends HttpServlet { 24 | 25 | BookService bookService = new BookServiceImpl(); 26 | 27 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 28 | PrintWriter pw = res.getWriter(); 29 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 30 | 31 | // Check if Customer is logged In 32 | if (!StoreUtil.isLoggedIn(UserRole.CUSTOMER, req.getSession())) { 33 | RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html"); 34 | rd.include(req, res); 35 | pw.println("
Please Login First to Continue!!
"); 36 | return; 37 | } 38 | try { 39 | // Add/Remove Item from the cart if requested 40 | // store the comma separated bookIds of cart in the session 41 | StoreUtil.updateCartItems(req); 42 | 43 | HttpSession session = req.getSession(); 44 | String bookIds = ""; 45 | if (session.getAttribute("items") != null) 46 | bookIds = (String) session.getAttribute("items");// read comma separated bookIds from session 47 | 48 | RequestDispatcher rd = req.getRequestDispatcher("CustomerHome.html"); 49 | rd.include(req, res); 50 | 51 | // Set the active tab as cart 52 | StoreUtil.setActiveTab(pw, "cart"); 53 | 54 | // Read the books from the database with the respective bookIds 55 | List books = bookService.getBooksByCommaSeperatedBookIds(bookIds); 56 | List cartItems = new ArrayList(); 57 | pw.println("
Shopping Cart
"); 58 | pw.println("\r\n" 59 | + " \r\n" 60 | + " \r\n" 61 | + " \r\n" 62 | + " \r\n" 63 | + " \r\n" 64 | + " \r\n" 65 | + " \r\n" 66 | + " \r\n" 67 | + " \r\n" 68 | + " \r\n" 69 | + " \r\n"); 70 | double amountToPay = 0; 71 | if (books == null || books.size() == 0) { 72 | pw.println(" \r\n" 73 | + " \r\n" 74 | + " \r\n"); 75 | } 76 | for (Book book : books) { 77 | int qty = (int) session.getAttribute("qty_" + book.getBarcode()); 78 | Cart cart = new Cart(book, qty); 79 | cartItems.add(cart); 80 | amountToPay += (qty * book.getPrice()); 81 | pw.println(getRowData(cart)); 82 | } 83 | 84 | // set cartItems and amountToPay in the session 85 | session.setAttribute("cartItems", cartItems); 86 | session.setAttribute("amountToPay", amountToPay); 87 | 88 | if (amountToPay > 0) { 89 | pw.println(" \r\n" 90 | + " \r\n" 91 | + " \r\n" 94 | + " \r\n"); 95 | } 96 | pw.println(" \r\n" 97 | + "
BookIdNameAuthorPrice/ItemQuantityAmount
No Items In the Cart
Total Amount To Pay " 92 | + amountToPay 93 | + "
"); 98 | if (amountToPay > 0) { 99 | pw.println("
\r\n" 100 | + "
" 101 | + "
" 103 | + "
"); 104 | } 105 | } catch (Exception e) { 106 | e.printStackTrace(); 107 | } 108 | } 109 | 110 | public String getRowData(Cart cart) { 111 | Book book = cart.getBook(); 112 | return " \r\n" 113 | + " " + book.getBarcode() + "\r\n" 114 | + " " + book.getName() + "\r\n" 115 | + " " + book.getAuthor() + "\r\n" 116 | + " " + book.getPrice() + "\r\n" 117 | + "
" 118 | + "" 119 | + cart.getQuantity() 120 | + "
\r\n" 121 | + " " + (book.getPrice() * cart.getQuantity()) + "\r\n" 122 | + " \r\n"; 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/servlets/CheckoutServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.RequestDispatcher; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | import com.bittercode.constant.BookStoreConstants; 13 | import com.bittercode.model.UserRole; 14 | import com.bittercode.util.StoreUtil; 15 | 16 | public class CheckoutServlet extends HttpServlet { 17 | public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 18 | PrintWriter pw = res.getWriter(); 19 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 20 | if (!StoreUtil.isLoggedIn(UserRole.CUSTOMER, req.getSession())) { 21 | RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html"); 22 | rd.include(req, res); 23 | pw.println("
Please Login First to Continue!!
"); 24 | return; 25 | } 26 | try { 27 | 28 | RequestDispatcher rd = req.getRequestDispatcher("payment.html"); 29 | rd.include(req, res); 30 | StoreUtil.setActiveTab(pw, "cart"); 31 | pw.println("Total Amount₹ " 32 | + req.getSession().getAttribute("amountToPay") 33 | + ""); 34 | 35 | pw.println("" 36 | + ""); 37 | 38 | pw.println("
\r\n" 39 | + "
\r\n" 40 | + "
\r\n" 41 | + "
"); 42 | } catch (Exception e) { 43 | e.printStackTrace(); 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/servlets/CustomerLoginServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.RequestDispatcher; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | import com.bittercode.constant.BookStoreConstants; 13 | import com.bittercode.constant.db.UsersDBConstants; 14 | import com.bittercode.model.User; 15 | import com.bittercode.model.UserRole; 16 | import com.bittercode.service.UserService; 17 | import com.bittercode.service.impl.UserServiceImpl; 18 | 19 | public class CustomerLoginServlet extends HttpServlet { 20 | 21 | UserService authService = new UserServiceImpl(); 22 | 23 | public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 24 | PrintWriter pw = res.getWriter(); 25 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 26 | String uName = req.getParameter(UsersDBConstants.COLUMN_USERNAME); 27 | String pWord = req.getParameter(UsersDBConstants.COLUMN_PASSWORD); 28 | User user = authService.login(UserRole.CUSTOMER, uName, pWord, req.getSession()); 29 | 30 | try { 31 | 32 | if (user != null) { 33 | 34 | RequestDispatcher rd = req.getRequestDispatcher("CustomerHome.html"); 35 | rd.include(req, res); 36 | pw.println("

Welcome to Online
Book Store

\r\n" 37 | + "
\r\n" 38 | + " \r\n" 39 | + " \r\n" 40 | + " \r\n" 41 | + " \r\n" 42 | + "

Welcome "+user.getFirstName()+", Happy Learning !!

"); 43 | 44 | } else { 45 | 46 | RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html"); 47 | rd.include(req, res); 48 | pw.println("
Incorrect UserName or PassWord
"); 49 | } 50 | 51 | } catch (Exception e) { 52 | e.printStackTrace(); 53 | } 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /src/main/java/servlets/CustomerRegisterServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.RequestDispatcher; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | import com.bittercode.constant.BookStoreConstants; 13 | import com.bittercode.constant.ResponseCode; 14 | import com.bittercode.constant.db.UsersDBConstants; 15 | import com.bittercode.model.User; 16 | import com.bittercode.model.UserRole; 17 | import com.bittercode.service.UserService; 18 | import com.bittercode.service.impl.UserServiceImpl; 19 | 20 | public class CustomerRegisterServlet extends HttpServlet { 21 | 22 | UserService userService = new UserServiceImpl(); 23 | 24 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 25 | PrintWriter pw = res.getWriter(); 26 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 27 | 28 | String pWord = req.getParameter(UsersDBConstants.COLUMN_PASSWORD); 29 | String fName = req.getParameter(UsersDBConstants.COLUMN_FIRSTNAME); 30 | String lName = req.getParameter(UsersDBConstants.COLUMN_LASTNAME); 31 | String addr = req.getParameter(UsersDBConstants.COLUMN_ADDRESS); 32 | String phNo = req.getParameter(UsersDBConstants.COLUMN_PHONE); 33 | String mailId = req.getParameter(UsersDBConstants.COLUMN_MAILID); 34 | User user = new User(); 35 | user.setEmailId(mailId); 36 | user.setFirstName(fName); 37 | user.setLastName(lName); 38 | user.setPassword(pWord); 39 | user.setPhone(Long.parseLong(phNo)); 40 | user.setAddress(addr); 41 | try { 42 | String respCode = userService.register(UserRole.CUSTOMER, user); 43 | System.out.println(respCode); 44 | if (ResponseCode.SUCCESS.name().equalsIgnoreCase(respCode)) { 45 | RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html"); 46 | rd.include(req, res); 47 | pw.println("
User Registered Successfully
"); 48 | } else { 49 | RequestDispatcher rd = req.getRequestDispatcher("CustomerRegister.html"); 50 | rd.include(req, res); 51 | pw.println("
" + respCode + "
"); 52 | pw.println("Sorry for interruption! Try again"); 53 | } 54 | } catch (Exception e) { 55 | e.printStackTrace(); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /src/main/java/servlets/ErrorHandlerServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.Optional; 6 | 7 | import javax.servlet.RequestDispatcher; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | import com.bittercode.constant.ResponseCode; 14 | import com.bittercode.model.StoreException; 15 | import com.bittercode.model.UserRole; 16 | import com.bittercode.util.StoreUtil; 17 | 18 | public class ErrorHandlerServlet extends HttpServlet { 19 | 20 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 21 | PrintWriter pw = res.getWriter(); 22 | res.setContentType("text/html"); 23 | 24 | // Fetch the exceptions 25 | Throwable throwable = (Throwable) req.getAttribute("javax.servlet.error.exception"); 26 | Integer statusCode = (Integer) req.getAttribute("javax.servlet.error.status_code"); 27 | String servletName = (String) req.getAttribute("javax.servlet.error.servlet_name"); 28 | String requestUri = (String) req.getAttribute("javax.servlet.error.request_uri"); 29 | String errorMessage = ResponseCode.INTERNAL_SERVER_ERROR.getMessage(); 30 | String errorCode = ResponseCode.INTERNAL_SERVER_ERROR.name(); 31 | 32 | if (statusCode == null) 33 | statusCode = 0; 34 | Optional errorCodes = ResponseCode.getMessageByStatusCode(statusCode); 35 | if (errorCodes.isPresent()) { 36 | errorMessage = errorCodes.get().getMessage(); 37 | errorCode = errorCodes.get().name(); 38 | } 39 | 40 | if (throwable != null && throwable instanceof StoreException) { 41 | StoreException storeException = (StoreException) throwable; 42 | if (storeException != null) { 43 | errorMessage = storeException.getMessage(); 44 | statusCode = storeException.getStatusCode(); 45 | errorCode = storeException.getErrorCode(); 46 | storeException.printStackTrace(); 47 | } 48 | } 49 | 50 | System.out.println("======ERROR TRIGGERED========"); 51 | System.out.println("Servlet Name: " + servletName); 52 | System.out.println("Request URI: " + requestUri); 53 | System.out.println("Status Code: " + statusCode); 54 | System.out.println("Error Code: " + errorCode); 55 | System.out.println("Error Message: " + errorMessage); 56 | System.out.println("============================="); 57 | 58 | if (StoreUtil.isLoggedIn(UserRole.CUSTOMER, req.getSession())) { 59 | RequestDispatcher rd = req.getRequestDispatcher("CustomerHome.html"); 60 | rd.include(req, res); 61 | StoreUtil.setActiveTab(pw, "home"); 62 | showErrorMessage(pw, errorCode, errorMessage); 63 | 64 | } else if (StoreUtil.isLoggedIn(UserRole.SELLER, req.getSession())) { 65 | RequestDispatcher rd = req.getRequestDispatcher("SellerHome.html"); 66 | rd.include(req, res); 67 | StoreUtil.setActiveTab(pw, "home"); 68 | showErrorMessage(pw, errorCode, errorMessage); 69 | 70 | } else { 71 | RequestDispatcher rd = req.getRequestDispatcher("index.html"); 72 | rd.include(req, res); 73 | pw.println(""); 77 | showErrorMessage(pw, errorCode, errorMessage); 78 | } 79 | 80 | } 81 | 82 | private void showErrorMessage(PrintWriter pw, String errorCode, String errorMessage) { 83 | pw.println("
" 84 | + "
\r\n" 85 | + "

" 86 | + errorCode 87 | + "

\r\n" 88 | + "
\r\n" 89 | + "

" 90 | + errorMessage 91 | + "

\r\n" 92 | + "
" 93 | + "
"); 94 | 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/servlets/LogoutServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.RequestDispatcher; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | import com.bittercode.constant.BookStoreConstants; 13 | import com.bittercode.service.UserService; 14 | import com.bittercode.service.impl.UserServiceImpl; 15 | 16 | public class LogoutServlet extends HttpServlet { 17 | 18 | UserService authService = new UserServiceImpl(); 19 | 20 | public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 21 | PrintWriter pw = res.getWriter(); 22 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 23 | try { 24 | 25 | boolean logout = authService.logout(req.getSession()); 26 | 27 | RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html"); 28 | rd.include(req, res); 29 | // StoreUtil.setActiveTab(pw, "logout"); 30 | if (logout) { 31 | pw.println("
Successfully logged out!
"); 32 | } 33 | 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /src/main/java/servlets/ProcessPaymentServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.List; 6 | 7 | import javax.servlet.RequestDispatcher; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import javax.servlet.http.HttpSession; 13 | 14 | import com.bittercode.constant.BookStoreConstants; 15 | import com.bittercode.model.Book; 16 | import com.bittercode.model.Cart; 17 | import com.bittercode.model.UserRole; 18 | import com.bittercode.service.BookService; 19 | import com.bittercode.service.impl.BookServiceImpl; 20 | import com.bittercode.util.StoreUtil; 21 | 22 | public class ProcessPaymentServlet extends HttpServlet { 23 | 24 | BookService bookService = new BookServiceImpl(); 25 | 26 | @SuppressWarnings("unchecked") 27 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 28 | PrintWriter pw = res.getWriter(); 29 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 30 | if (!StoreUtil.isLoggedIn(UserRole.CUSTOMER, req.getSession())) { 31 | RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html"); 32 | rd.include(req, res); 33 | pw.println("
Please Login First to Continue!!
"); 34 | return; 35 | } 36 | try { 37 | 38 | RequestDispatcher rd = req.getRequestDispatcher("CustomerHome.html"); 39 | rd.include(req, res); 40 | StoreUtil.setActiveTab(pw, "cart"); 41 | pw.println("
Your Orders
"); 42 | pw.println("
\r\n" 43 | + "
"); 44 | HttpSession session = req.getSession(); 45 | List cartItems = null; 46 | if (session.getAttribute("cartItems") != null) 47 | cartItems = (List) session.getAttribute("cartItems"); 48 | for (Cart cart : cartItems) { 49 | Book book = cart.getBook(); 50 | double bPrice = book.getPrice(); 51 | String bCode = book.getBarcode(); 52 | String bName = book.getName(); 53 | String bAuthor = book.getAuthor(); 54 | int availableQty = book.getQuantity(); 55 | int qtToBuy = cart.getQuantity(); 56 | availableQty = availableQty - qtToBuy; 57 | bookService.updateBookQtyById(bCode, availableQty); 58 | pw.println(this.addBookToCard(bCode, bName, bAuthor, bPrice, availableQty)); 59 | session.removeAttribute("qty_" + bCode); 60 | } 61 | session.removeAttribute("amountToPay"); 62 | session.removeAttribute("cartItems"); 63 | session.removeAttribute("items"); 64 | session.removeAttribute("selectedBookId"); 65 | pw.println("
\r\n" 66 | + "
"); 67 | } catch (Exception e) { 68 | e.printStackTrace(); 69 | } 70 | } 71 | 72 | public String addBookToCard(String bCode, String bName, String bAuthor, double bPrice, int bQty) { 73 | String button = "Order Placed\r\n"; 74 | return "
\r\n" 75 | + "
\r\n" 76 | + " \"Card\r\n" 77 | + "
\r\n" 78 | + "
" + bName + "
\r\n" 79 | + "

\r\n" 80 | + " Author: " + bAuthor 81 | + "
\r\n" 82 | + "

\r\n" 83 | + " \r\n" 84 | + "
\r\n" 85 | + "
\r\n" 86 | + "
\r\n" 87 | + "
\r\n" 88 | + "

\r\n" 89 | + " Order Id: ORD" + bCode + "TM \r\n" 90 | + "
Item Yet to be Delivered\r\n" 91 | + "

\r\n" 92 | + "
\r\n" 93 | + "
\r\n" 94 | + "

\r\n" 95 | + " Amout Paid: ₹ " + bPrice 96 | + " \r\n" 97 | + "

\r\n" 98 | + button 99 | + "
\r\n" 100 | + "
\r\n" 101 | + "
"; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/servlets/ReceiptServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.List; 6 | 7 | import javax.servlet.RequestDispatcher; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | import com.bittercode.constant.BookStoreConstants; 14 | import com.bittercode.model.Book; 15 | import com.bittercode.model.UserRole; 16 | import com.bittercode.service.BookService; 17 | import com.bittercode.service.impl.BookServiceImpl; 18 | import com.bittercode.util.StoreUtil; 19 | 20 | public class ReceiptServlet extends HttpServlet { 21 | BookService bookService = new BookServiceImpl(); 22 | 23 | //NOT_IN_USED 24 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 25 | PrintWriter pw = res.getWriter(); 26 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 27 | if (!StoreUtil.isLoggedIn(UserRole.CUSTOMER, req.getSession())) { 28 | RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html"); 29 | rd.include(req, res); 30 | pw.println("
Please Login First to Continue!!
"); 31 | return; 32 | } 33 | try { 34 | List books = bookService.getAllBooks(); 35 | int i = 0; 36 | RequestDispatcher rd = req.getRequestDispatcher("CustomerHome.html"); 37 | rd.include(req, res); 38 | StoreUtil.setActiveTab(pw, "cart"); 39 | pw.println("
Your order status is as below
"); 40 | pw.println( 41 | "
\r\n" + " \r\n" + " \r\n" + " \r\n" 42 | + " \r\n" + " \r\n" 43 | + " \r\n" + " \r\n" 44 | + "
\r\n" + "
\r\n" 45 | + " "); 46 | double total = 0.0; 47 | for (Book book : books) { 48 | double bPrice = book.getPrice(); 49 | String bCode = book.getBarcode(); 50 | String bName = book.getName(); 51 | String bAuthor = book.getAuthor(); 52 | int bQty = book.getQuantity(); 53 | i = i + 1; 54 | 55 | String qt = "qty" + Integer.toString(i); 56 | int quantity = Integer.parseInt(req.getParameter(qt)); 57 | try { 58 | String check1 = "checked" + Integer.toString(i); 59 | String getChecked = req.getParameter(check1); 60 | if (bQty < quantity) { 61 | pw.println( 62 | "
Book CodeBook NameBook AuthorBook PriceQuantityAmount
Please Select the Qty less than Available Books Quantity
"); 63 | break; 64 | } 65 | 66 | if (getChecked.equals("pay")) { 67 | pw.println("" + bCode + ""); 68 | pw.println("" + bName + ""); 69 | pw.println("" + bAuthor + ""); 70 | pw.println("" + bPrice + ""); 71 | pw.println("" + quantity + ""); 72 | double amount = bPrice * quantity; 73 | total = total + amount; 74 | pw.println("" + amount + ""); 75 | bQty = bQty - quantity; 76 | System.out.println(bQty); 77 | bookService.updateBookQtyById(bCode, bQty); 78 | } 79 | } catch (Exception e) { 80 | } 81 | } 82 | pw.println("
Total Paid Amount: " + total + "
"); 83 | // String fPay = req.getParameter("f_pay"); 84 | } catch (Exception e) { 85 | e.printStackTrace(); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/servlets/RemoveBookServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.RequestDispatcher; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | import com.bittercode.constant.ResponseCode; 13 | import com.bittercode.model.UserRole; 14 | import com.bittercode.service.BookService; 15 | import com.bittercode.service.impl.BookServiceImpl; 16 | import com.bittercode.util.StoreUtil; 17 | 18 | public class RemoveBookServlet extends HttpServlet { 19 | 20 | BookService bookService = new BookServiceImpl(); 21 | 22 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 23 | PrintWriter pw = res.getWriter(); 24 | res.setContentType("text/html"); 25 | if (!StoreUtil.isLoggedIn(UserRole.SELLER, req.getSession())) { 26 | RequestDispatcher rd = req.getRequestDispatcher("SellerLogin.html"); 27 | rd.include(req, res); 28 | pw.println("
Please Login First to Continue!!
"); 29 | return; 30 | } 31 | 32 | try { 33 | String bookId = req.getParameter("bookId"); 34 | RequestDispatcher rd = req.getRequestDispatcher("SellerHome.html"); 35 | rd.include(req, res); 36 | StoreUtil.setActiveTab(pw, "removebook"); 37 | pw.println("
"); 38 | if (bookId == null || bookId.isBlank()) { 39 | // render the remove book form; 40 | showRemoveBookForm(pw); 41 | return; 42 | } // else continue 43 | 44 | String responseCode = bookService.deleteBookById(bookId.trim()); 45 | if (ResponseCode.SUCCESS.name().equalsIgnoreCase(responseCode)) { 46 | pw.println("
Book Removed Successfully
"); 47 | pw.println( 48 | "
Remove more Books
"); 49 | 50 | } else { 51 | pw.println("
Book Not Available In The Store
"); 52 | pw.println( 53 | "
Remove more Books
"); 54 | } 55 | pw.println("
"); 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | pw.println("
Failed to Remove Books! Try Again
"); 59 | } 60 | } 61 | 62 | private static void showRemoveBookForm(PrintWriter pw) { 63 | String form = "
\r\n" 64 | + " \r\n" 65 | + " \r\n" 66 | + " \r\n" 71 | + " \r\n" 72 | + "\r\n" 73 | + "
\r\n" 67 | + " \r\n" 68 | + " \r\n" 69 | + " \r\n" 70 | + "
\r\n" 74 | + "
"; 75 | pw.println(form); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/servlets/SellerLoginServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.RequestDispatcher; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | import com.bittercode.constant.BookStoreConstants; 13 | import com.bittercode.constant.db.UsersDBConstants; 14 | import com.bittercode.model.User; 15 | import com.bittercode.model.UserRole; 16 | import com.bittercode.service.UserService; 17 | import com.bittercode.service.impl.UserServiceImpl; 18 | 19 | public class SellerLoginServlet extends HttpServlet { 20 | 21 | UserService userService = new UserServiceImpl(); 22 | 23 | public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 24 | PrintWriter pw = res.getWriter(); 25 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 26 | String uName = req.getParameter(UsersDBConstants.COLUMN_USERNAME); 27 | String pWord = req.getParameter(UsersDBConstants.COLUMN_PASSWORD); 28 | try { 29 | User user = userService.login(UserRole.SELLER, uName, pWord, req.getSession()); 30 | if (user != null) { 31 | RequestDispatcher rd = req.getRequestDispatcher("SellerHome.html"); 32 | 33 | rd.include(req, res); 34 | pw.println("

Welcome to Online
Book Store

\r\n" 35 | + "
\r\n" 36 | + " \r\n" 37 | + " \r\n" 38 | + " \r\n" 39 | + " \r\n" 40 | + "

Welcome "+user.getFirstName()+", Happy Learning !!

"); 41 | } else { 42 | 43 | RequestDispatcher rd = req.getRequestDispatcher("SellerLogin.html"); 44 | rd.include(req, res); 45 | pw.println("
Incorrect UserName or PassWord
"); 46 | } 47 | 48 | } catch (Exception e) { 49 | e.printStackTrace(); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/main/java/servlets/StoreBookServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.List; 6 | 7 | import javax.servlet.RequestDispatcher; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | import com.bittercode.model.Book; 14 | import com.bittercode.model.UserRole; 15 | import com.bittercode.service.BookService; 16 | import com.bittercode.service.impl.BookServiceImpl; 17 | import com.bittercode.util.StoreUtil; 18 | 19 | public class StoreBookServlet extends HttpServlet { 20 | 21 | // book service for database operations and logics 22 | BookService bookService = new BookServiceImpl(); 23 | 24 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 25 | PrintWriter pw = res.getWriter(); 26 | res.setContentType("text/html"); 27 | 28 | // Check if the customer is logged in, or else return to login page 29 | if (!StoreUtil.isLoggedIn(UserRole.SELLER, req.getSession())) { 30 | RequestDispatcher rd = req.getRequestDispatcher("SellerLogin.html"); 31 | rd.include(req, res); 32 | pw.println("
Please Login First to Continue!!
"); 33 | return; 34 | } 35 | try { 36 | 37 | // Add/Remove Item from the cart if requested 38 | // store the comma separated bookIds of cart in the session 39 | // StoreUtil.updateCartItems(req); 40 | 41 | RequestDispatcher rd = req.getRequestDispatcher("SellerHome.html"); 42 | rd.include(req, res); 43 | pw.println("
"); 44 | // Set the active tab as cart 45 | StoreUtil.setActiveTab(pw, "storebooks"); 46 | 47 | // Read the books from the database with the respective bookIds 48 | List books = bookService.getAllBooks(); 49 | pw.println("
Books Available In the Store
"); 50 | pw.println("\r\n" 51 | + " \r\n" 52 | + " \r\n" 53 | + " \r\n" 54 | + " \r\n" 55 | + " \r\n" 56 | + " \r\n" 57 | + " \r\n" 58 | + " \r\n" 59 | + " \r\n" 60 | + " \r\n" 61 | + " \r\n"); 62 | if (books == null || books.size() == 0) { 63 | pw.println(" \r\n" 64 | + " \r\n" 65 | + " \r\n"); 66 | } 67 | for (Book book : books) { 68 | pw.println(getRowData(book)); 69 | } 70 | 71 | pw.println(" \r\n" 72 | + "
BookIdNameAuthorPriceQuantityAction
No Books Available in the store
"); 73 | 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | } 77 | } 78 | 79 | public String getRowData(Book book) { 80 | return " \r\n" 81 | + " " + book.getBarcode() + "\r\n" 82 | + " " + book.getName() + "\r\n" 83 | + " " + book.getAuthor() + "\r\n" 84 | + " " + book.getPrice() + "\r\n" 85 | + " " 86 | + book.getQuantity() 87 | + " \r\n" 88 | + "
" 89 | + " " 90 | + " " 91 | + "
" 92 | + " \r\n"; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/servlets/UpdateBookServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | 6 | import javax.servlet.RequestDispatcher; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | import com.bittercode.constant.BookStoreConstants; 13 | import com.bittercode.constant.ResponseCode; 14 | import com.bittercode.constant.db.BooksDBConstants; 15 | import com.bittercode.model.Book; 16 | import com.bittercode.model.UserRole; 17 | import com.bittercode.service.BookService; 18 | import com.bittercode.service.impl.BookServiceImpl; 19 | import com.bittercode.util.StoreUtil; 20 | 21 | public class UpdateBookServlet extends HttpServlet { 22 | BookService bookService = new BookServiceImpl(); 23 | 24 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 25 | PrintWriter pw = res.getWriter(); 26 | res.setContentType(BookStoreConstants.CONTENT_TYPE_TEXT_HTML); 27 | 28 | if (!StoreUtil.isLoggedIn(UserRole.SELLER, req.getSession())) { 29 | RequestDispatcher rd = req.getRequestDispatcher("SellerLogin.html"); 30 | rd.include(req, res); 31 | pw.println("
Please Login First to Continue!!
"); 32 | return; 33 | } 34 | 35 | RequestDispatcher rd = req.getRequestDispatcher("SellerHome.html"); 36 | rd.include(req, res); 37 | StoreUtil.setActiveTab(pw, "storebooks"); 38 | pw.println("
"); 39 | 40 | try { 41 | if (req.getParameter("updateFormSubmitted") != null) { 42 | String bName = req.getParameter(BooksDBConstants.COLUMN_NAME); 43 | String bCode = req.getParameter(BooksDBConstants.COLUMN_BARCODE); 44 | String bAuthor = req.getParameter(BooksDBConstants.COLUMN_AUTHOR); 45 | double bPrice = Double.parseDouble(req.getParameter(BooksDBConstants.COLUMN_PRICE)); 46 | int bQty = Integer.parseInt(req.getParameter(BooksDBConstants.COLUMN_QUANTITY)); 47 | 48 | Book book = new Book(bCode, bName, bAuthor, bPrice, bQty); 49 | String message = bookService.updateBook(book); 50 | if (ResponseCode.SUCCESS.name().equalsIgnoreCase(message)) { 51 | pw.println( 52 | "
Book Detail Updated Successfully!
"); 53 | } else { 54 | pw.println("
Failed to Update Book!!
"); 55 | // rd.include(req, res); 56 | } 57 | 58 | return; 59 | } 60 | 61 | String bookId = req.getParameter("bookId"); 62 | 63 | if (bookId != null) { 64 | Book book = bookService.getBookById(bookId); 65 | showUpdateBookForm(pw, book); 66 | } 67 | 68 | } catch (Exception e) { 69 | e.printStackTrace(); 70 | pw.println("
Failed to Load Book data!!
"); 71 | } 72 | } 73 | 74 | private static void showUpdateBookForm(PrintWriter pw, Book book) { 75 | String form = "\r\n" 76 | + " \r\n" 77 | + " \r\n" 92 | + " \r\n" 93 | + "
\r\n" 78 | + "
\r\n" 79 | + "
" 81 | + "
\r\n" 83 | + "
\r\n" 85 | + "
\r\n" 87 | + "
\r\n" 89 | + " \r\n" 90 | + "
\r\n" 91 | + "
"; 94 | pw.println(form); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/servlets/ViewBookServlet.java: -------------------------------------------------------------------------------- 1 | package servlets; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.util.List; 6 | 7 | import javax.servlet.RequestDispatcher; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import javax.servlet.http.HttpSession; 13 | 14 | import com.bittercode.model.Book; 15 | import com.bittercode.model.UserRole; 16 | import com.bittercode.service.BookService; 17 | import com.bittercode.service.impl.BookServiceImpl; 18 | import com.bittercode.util.StoreUtil; 19 | 20 | public class ViewBookServlet extends HttpServlet { 21 | 22 | // book service for database operations and logics 23 | BookService bookService = new BookServiceImpl(); 24 | 25 | public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 26 | PrintWriter pw = res.getWriter(); 27 | res.setContentType("text/html"); 28 | 29 | // Check if the customer is logged in, or else return to login page 30 | if (!StoreUtil.isLoggedIn(UserRole.CUSTOMER, req.getSession())) { 31 | RequestDispatcher rd = req.getRequestDispatcher("CustomerLogin.html"); 32 | rd.include(req, res); 33 | pw.println("
Please Login First to Continue!!
"); 34 | return; 35 | } 36 | try { 37 | 38 | // Read All available books from the database 39 | List books = bookService.getAllBooks(); 40 | 41 | // Default Page to load data into 42 | RequestDispatcher rd = req.getRequestDispatcher("CustomerHome.html"); 43 | rd.include(req, res); 44 | 45 | // Set Available Books tab as active 46 | StoreUtil.setActiveTab(pw, "books"); 47 | 48 | // Show the heading for the page 49 | pw.println("
Available Books" 50 | + "
" 51 | + "
" 52 | + "
"); 53 | pw.println("
\r\n" 54 | + "
"); 55 | 56 | // Add or Remove items from the cart, if requested 57 | StoreUtil.updateCartItems(req); 58 | 59 | HttpSession session = req.getSession(); 60 | for (Book book : books) { 61 | 62 | // Add each book to display as a card 63 | pw.println(this.addBookToCard(session, book)); 64 | 65 | } 66 | 67 | // Checkout Button 68 | pw.println("
" 69 | + "
" 70 | + "
" 71 | + "
"); 72 | 73 | } catch (Exception e) { 74 | e.printStackTrace(); 75 | } 76 | } 77 | 78 | public String addBookToCard(HttpSession session, Book book) { 79 | String bCode = book.getBarcode(); 80 | int bQty = book.getQuantity(); 81 | 82 | // Quantity of the current book added to the cart 83 | int cartItemQty = 0; 84 | if (session.getAttribute("qty_" + bCode) != null) { 85 | // Quantity of each book in the cart will be added in the session prefixed with 86 | // 'qty_' following with bookId 87 | cartItemQty = (int) session.getAttribute("qty_" + bCode); 88 | } 89 | 90 | // Button To Add/Remove item from the cart 91 | String button = ""; 92 | if (bQty > 0) { 93 | // If no items in the cart, show add to cart button 94 | // If items is added to the cart, then show +, - button to add/remove more items 95 | button = "
" 96 | + "" 97 | + "" 98 | + (cartItemQty == 0 99 | ? "
" 100 | : "
" 101 | + " " 102 | + "" 103 | + cartItemQty 104 | + "
") 105 | + ""; 106 | } else { 107 | // If available Quantity is zero, show out of stock button 108 | button = "

Out Of Stock

\r\n"; 109 | } 110 | 111 | // Bootstrap card to show the book data 112 | return "
\r\n" 113 | + "
\r\n" 114 | + " \"Card\r\n" 115 | + "
\r\n" 116 | + "
" + book.getName() + "
\r\n" 117 | + "

\r\n" 118 | + " Author: " 119 | + book.getAuthor() 120 | + "
\r\n" 121 | + "

\r\n" 122 | + " \r\n" 123 | + "
\r\n" 124 | + "
\r\n" 125 | + "
\r\n" 126 | + "
\r\n" 127 | + "

\r\n" 128 | + " Id: " + bCode + "\r\n" 129 | + (bQty < 20 ? "
Only " + bQty + " items left\r\n" 130 | : "
Trending\r\n") 131 | + "

\r\n" 132 | + "
\r\n" 133 | + "
\r\n" 134 | + "

\r\n" 135 | + " Price: ₹ " 136 | + book.getPrice() 137 | + " \r\n" 138 | + "

\r\n" 139 | + button 140 | + "
\r\n" 141 | + "
\r\n" 142 | + "
"; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | db.driver=com.mysql.cj.jdbc.Driver 2 | db.host=jdbc:mysql://localhost 3 | db.port=3306 4 | db.name=onlinebookstore 5 | db.username=root 6 | db.password=root --------------------------------------------------------------------------------