Deploying WAR file to Tomcat

In this post, I will continue to go thru the steps required to deploy a WAR file to the raspberry pi. And yes, it will works for other linux based system.

To deploy the WAR file, simply copy the WAR file to /opt/tomcat9/webapps/ folder and restart the tomcat server. The extraction and deployment of the WAR file will start automatically.

For example if your WAR file is named as jack.war, you could simply browse to http://localhost:8080/jack on your browsers to check that it is working.

Next if you want to change the default port in which Tomcat listen to, you would have to head over to /opt/tomcat9/conf/server.xml, below is the default


<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

Personally I had changed it to port 80 as can be seen below.


<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

Reference used
http://www.mkyong.com/tomcat/how-to-install-apache-tomcat-8-on-debian/

Posted in apache tomcat, Raspberry Pi | Tagged , , , , | Leave a comment

Backup a img of Raspbian for Raspberry Pi

We cannot deny that it is important to always backup your data. It is even much more important to backup your entire Raspberry Pi SD card after going thru so much to setting up all the configuration which you never want to go thru again.

Therefore you should create a img of the SD card by doing the below on either a Linux or Mac machine


sudo dd bs=1M if=/dev/sdb of=raspbian.img

To restore from the img, simply do the below


sudo dd bs=1M if=raspbian.img of=/dev/sdb

While the Raspberry Pi Foundation recommend us to use bs=4M, it does not seem to work for me and hence I had decided to go with bs=1M even though it might be a lot slower but it works.

Just to note, if you are running Raspbian Jessie on Raspberry Pi 2, using the exact same SD card or img on a Raspberry Pi 3 is perfectly fine. There is no need for further configuration and it works out of the box. The only thing is that you might want to do a “sudo apt-get update” to fetch some of the specific updates for Raspberry Pi 3 hardware.

Posted in Raspberry Pi | Tagged , , , , , , | Leave a comment

Tomcat: redirecting traffic from port 8080 to 80 using iptables

Glass Onion Blog

First verify that Tomcat is running on port 8080. Run the following command

# netstat -ntl

The output will look something like

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN
tcp        0      0 ::ffff:127.0.0.1:8005       :::*                        LISTEN
tcp        0      0 :::8009                     :::*                        LISTEN
tcp        0      0 :::8080                     :::*                        LISTEN
tcp        0      0 :::22                       :::*                        LISTEN

Run the following command to redirect port 80 traffic to port 8080

# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

Run the folloing command to verify that redirect is working fine

# iptables -t nat -L

The output will look something like

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
REDIRECT   tcp  --  anywhere             anywhere            tcp dpt:http redir ports 8080 Chain OUTPUT (policy ACCEPT) target     prot opt source               destination Chain POSTROUTING (policy…

View original post 28 more words

Posted in Uncategorized | Leave a comment

Correctly switch between 2 Column and 1 Column grid on iPhone Landscape/Portrait mode

I had been designing a website with 4 banner that each takes col-md-3 for desktop-sized screen and takes col-xs-12 on portrait mode on the iPhone.

//screenshot will be added in a short moment.

It turned out that it looks horrible on landscape mode as the banner are over-stretched. In this post, with the help of xander, we had managed to successfully put up 2 column of grid on the landscape mode. The main issue here is that on the landscape mode, the iphone will only use c0l-xs as such we have to force it to use col-sm.


@media only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 568px) {
.col-sm-6 {
float: left;
width: 50%;
}
}
Posted in Web Development | Tagged , , , | Leave a comment

Configuring App Transport Security Exceptions in iOS 9 and OSX 10.11

Steven Peterson

What is App Transport Security (ATS)?

At WWDC 2015, Apple announced “App Transport Security” for iOS 9 and OSX 10.11 El Capitan. The “What’s New in iOS” guide for iOS 9 explains:

App Transport Security (ATS) lets an app add a declaration to its Info.plist file that specifies the domains with which it needs secure communication. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.

If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible.

In simple terms, this means that if your application attempts to connect to any HTTP server…

View original post 549 more words

Posted in Uncategorized | Leave a comment

Mass download of files via wget

A couple of days ago Eric Ligman, Microsoft Director of Sales Excellence had posted on the give away of free Microsoft eBooks. The list of eBook for give away is indeed long and in this post, I will be teaching you how to download them all with just two commands in linux.

The first command download the list of free ebook, the second command visit each of the link in the txt file and download them and save it as the name given from the server. Without the “–content-disposition –trust-server-names” option, the file will simply be save as the last portion of the url.


wget <a href="http://www.mssmallbiz.com/ericligman/Key_Shorts/MSFTFreeEbooks.txt">http://www.mssmallbiz.com/eri…/Key_Shorts/MSFTFreeEbooks.txt</a>
wget --content-disposition --trust-server-names -i MSFTFreeEbooks.txt

You may visit the original link from Eric Ligman here

Lastly this guide won’t be possible without help of unix stackexchange

Posted in Uncategorized | Tagged , , | Leave a comment

Creating Jar for JavaFX Application

This is a step by step guide to creating a Jar for a JavaFX Application using IntelliJ IDEA. It is only tested on IntelliJ IDEA 2016 with Java8. Steps might be slightly different for Java7.

First, open up File > Project Structure.

Next click on Artifacts as shown below.

step1

Next click on the plus icon to add a Jar From modules with dependencies… as shown.

step2

Once the above step is completed, the below pop-up will be shown. Select your main class. This will be the class that is accessed when your app launches. It is typically Main.java or something similar. Click OK twice to exit the pop-up and Project Structure.

step3

Now to generate the jar file, go to Build > Build Artifacts…

step4

Once you clicked on the Build Artifacts, the below will be shown, select Build for the Action. Once clicked, the jar will be generated in the folder /out/artifacts/ and you can run the jar file directly from it.

step5

Posted in Java, JavaFX | Tagged , , | Leave a comment