Java : Spring MVC serve static content

Create a folder under webapp named resources . Now put all the static contents like css, js files into  resources folder.


Now map this folder path in mvc-dispatcher-servlet.xml ( See Line 25 )

Git Tutorial A


1. Create a repository on github
2. In Command line Move to your local project directory

Execute,

3. git add .
4. git commit -m "Commit Comment"
5. git remote add origin "remote repository URL"
** At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL.
6. git remote -v
7. git push origin master

Now visit Github repository, your project is there.
Now to add new file

1. git add .
2. git commit -m "Commit Comment"
3. git push origin master


JPhotoUploader Usage & Documentation

JPhotoUploader is an open source java library to share image online easily. Also one can embedded it in any java project. The project uses upload.im site's api to host image files. The site has no limitation but only maximum image file size limit is 64MB. It's also useable in any Android project.






: Options :
All : Uses this option to upload all added files.
Selected : Use this option to upload a specific file.
Add : Use it to add files.

Upload : Use it to start uploading files.
Reset : Use it to reset panel.
Donate : This is for donation purpose.


Emdedded in Application
You can embedded this library in any java and android application.
Classes :

Upload Single File
JPhotoUploader jPhotoUploader = new JPhotoUploader();
jPhotoUploader.add(new File("/Users/s4kib/Desktop/bangladesh.jpg"));
JResponse jResponse = jPhotoUploader.upload();

System.out.println(jResponse.getResponse());
System.out.println(jResponse.getPhotoName());
System.out.println(jResponse.getPhotoURL());
System.out.println(jResponse.getPhotoViewURL());
System.out.println(jResponse.getPhotoWidth());
System.out.println(jResponse.getPhotoHeight());
System.out.println(jResponse.getPhotoThumbURL());
System.out.println(jResponse.getPhotoThumbWidth());
System.out.println(jResponse.getPhotoThumbHeight());
System.out.println(jResponse.getPhotoSize());
Upload Multiple Files :
JPhotoUploader jPhotoUploader = new JPhotoUploader();

// Add all files in a list
ArrayList<File> files = new ArrayList<>();
files.add(new File("/Users/s4kib/Desktop/bangladesh.jpg"));
files.add(new File("/Users/s4kib/Desktop/bangladesh2.jpg"));
files.add(new File("/Users/s4kib/Desktop/bangladesh3.jpg"));

// Call addAll to add all files
jPhotoUploader.addAll(files);

// Call uploadAll to upload all files
ArrayList<JResponse> jResponses = jPhotoUploader.uploadAll();

// jPhotoUploader.upload(2); // To upload a specific file from list

for (JResponse jResponse : jResponses) {
    System.out.println(jResponse.getResponse());
    System.out.println(jResponse.getPhotoName());
    System.out.println(jResponse.getPhotoURL());
    System.out.println(jResponse.getPhotoViewURL());
    System.out.println(jResponse.getPhotoWidth());
    System.out.println(jResponse.getPhotoHeight());
    System.out.println(jResponse.getPhotoThumbURL());
    System.out.println(jResponse.getPhotoThumbWidth());
    System.out.println(jResponse.getPhotoThumbHeight());
    System.out.println(jResponse.getPhotoSize());
}

Licensing

The Project is available under two licenses, the GPL and a commercial license. If you are willing to integrate this project into a close source application, please contact me at s4kibs4mi at gmail.com. Thank you.

Enable Self Signed SSL on Ubuntu with Apache & Tomcat

Apache2 :

1. Generate Key ( 1024 Bit Long )
    openssl genrsa -des3 -out server.key 1024

2. Generate a CSR ( Certificate Signing Request )
    openssl req -new -key server.key -out server.csr

    sudo rm -Rf /etc/apache2/ssl
    sudo mkdir /etc/apache2/ssl

3. Generating a Self-Signed Certificate
    openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Country Name (2 letter code) [AU]:BD
State or Province Name (full name) [Some-State]:Dhaka
Locality Name (eg, city) []:Dhaka
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Company Name
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:Your Full Domain Name
Email Address []:your email address

Java : MongoDB - Installation & Setup

Installation :

   OSX :

brew install mongodb
brew install mongodb --with-openssl # with SSL support

sudo mongod
sudo mongod --auth # Authentication Mode
sudo mongod --fork # Run on different thread

Ubuntu :

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod start
sudo service mongod stop
sudo service mongod restart