Seller can add product image. The images are saved on local file system of server outside of the WAR. Image name is saved in database corresponding to the product. Tomcat can be configured to read files from anywhere on disk and serve them on a specific URL.
Add the Context tag in the conf/server.xml file, docBase attribute is the absolute path to the folder on your local file system and path attribute will be used by Tomcat to access that folder. Make sure Tomcat has permissions to read/write the specified location.
<Host appBase="webapps"
autoDeploy="false" name="localhost" unpackWARs="true"
xmlNamespaceAware="false" xmlValidation="false">
...
<Context docBase="/Users/sanul/Documents/uploads/" path="/media" />
</Host>For example, If I store myImage.jpg in /Users/sanul/Documents/uploads/ folder then using Tomcat server I can access that file in my browser using the following link
http://localhost:8080/media/myImage.jpg
server.xml using EclipseNote : Create folder to upload images outside workspace.
$ cd OnlineAuction/src/com/auctivity/utility
$ vim DBConnection.javaAdd derby URL, username and password
con = DriverManager.getConnection(url,username,password);$ cd OnlineAuction/src/com/auctivity/controller
$ vim AddProductController.javaAdd BASE_DIR as the image upload folder path in doPost method
String BASE_DIR = "/Users/sanul/Documents/";Run the /OnlineAuction/AuctivitySchema.sql
.
├── AuctivitySchema.sql
├── WebContent
│ ├── META-INF
│ │ └── MANIFEST.MF
│ ├── WEB-INF
│ │ ├── properties
│ │ │ └── log4j.properties
│ │ └── web.xml
│ ├── accounts
│ │ ├── login.jsp
│ │ ├── profile.jsp
│ │ └── registration.jsp
│ ├── buyer
│ │ └── buyerHistory.jsp
│ ├── common
│ │ ├── footer.jsp
│ │ └── navbar.jsp
│ ├── error
│ │ ├── comingSoon.jsp
│ │ ├── forbiddenAccessError.jsp
│ │ └── pageNotFoundError.jsp
│ ├── index.jsp
│ ├── resources
│ │ ├── css
│ │ │ ├── accounts
│ │ │ │ ├── login.css
│ │ │ │ ├── profile.css
│ │ │ │ └── registration.css
│ │ │ ├── buyer
│ │ │ │ └── buyerPagePurchasedProducts1.css
│ │ │ ├── home.css
│ │ │ ├── seller
│ │ │ │ ├── SellerNavbar.css
│ │ │ │ ├── SellerPage.css
│ │ │ │ └── addProducts.css
│ │ │ └── style.css
│ │ ├── img
│ │ │ └── logo.jpg
│ │ └── js
│ │ ├── accounts
│ │ │ ├── login.js
│ │ │ └── register.js
│ │ ├── buyer
│ │ ├── home.js
│ │ ├── index.js
│ │ ├── seller
│ │ │ ├── addProducts.js
│ │ │ └── scheduleAuction.js
│ │ └── utility
│ │ └── inputValidation.js
│ └── seller
│ ├── addProduct.jsp
│ ├── scheduleAuction.jsp
│ └── sellerHistory.jsp
├── derby.log
└── src
└── com
└── auctivity
├── controller
│ ├── AddProductController.java
│ ├── BuyerHistoryController.java
│ ├── DefaultController.java
│ ├── ExceptionController.java
│ ├── LogOutController.java
│ ├── LoginController.java
│ ├── ProfileController.java
│ ├── RegistrationController.java
│ ├── ScheduleAuctionController.java
│ └── SellerHistoryController.java
├── exceptions
│ ├── ForbiddenAccessException.java
│ ├── InsufficientBalanceException.java
│ ├── InvalidDataFormatException.java
│ └── UserNotFoundException.java
├── model
│ ├── beans
│ │ ├── Bid.java
│ │ ├── Category.java
│ │ ├── Product.java
│ │ ├── ProductForAuction.java
│ │ └── User.java
│ ├── dao
│ │ ├── IProductDao.java
│ │ ├── IProductSchedulerDao.java
│ │ ├── IUserDao.java
│ │ ├── ProductDaoImpl.java
│ │ ├── ProductSchedulerDaoImpl.java
│ │ └── UserDaoImpl.java
│ └── service
│ ├── IProductSchedulerService.java
│ ├── IProductService.java
│ ├── IUserService.java
│ ├── ProductSchedulerServiceImpl.java
│ ├── ProductServiceImpl.java
│ └── UserServiceImpl.java
└── utility
├── ContextListener.java
├── DBConnection.java
├── InputValidation.java
├── MyTimerTask.java
├── ObjectFactory.java
└── PasswordEncrypter.java