Monday, October 22, 2012

Windows 8 Tips

Windows 8 has some advantages and disadvantages.  The advantages are it seems to run much faster than previous versions and the start up time is very quick!  Also, the new Windows 8 Interface offers a cool way to get full screen apps via the Microsoft Store.  One huge disadvantage is the start menu has been redesigned and may take some getting used to now.  Also, switching between the desktop and the Windows 8 interface can be a little annoying.

So, here are some tips to help you get used to the new OS.

Start Menu
Aim the mouse to the bottom left corner of the screen and then click on the Start Box that comes up.  Also, you can simply press the "Windows" button if your keyboard has one, or you can press Ctrl-Esc.

Shutdown/Restart
This was the hardest thing for me to get used to.  However, once you know the trick its easy.  Press Windows Button and C at the same time, then on the right you should see the "Settings" button.  Press that button, then Press Power and you get the option to Sleep, Restart, or Shutdown.  Another way to get to this option is to move the mouse down to the lower right corner of the screen.

Switch to Open "Windows 8" Apps
Move the mouse to the top left corner of the screen and you will see a list of "running" Windows 8 apps.  If you do not have any open, then nothing will appear.

Search
Move your mouse either to the top right or the bottom right and you will see an overlay appear.  Then you can click on the Search Icon ( magnifying glass ).  Another quick way is Windows Button + C and then click the search icon.

Quitting a Windows 8 App
Despite what you may think, pressing Escape will not let you exit a Windows 8 app.  You can press the Windows Button ( ctrl-esc ) which will let the app continue to run, but you will get back to the start menu, or you can press alt-f4.  Also, you can grab the top of the app using the mouse and pull it down to the bottom to close at as well.  This can be done with the mouse or using the touch screen.

Snapped View
In Windows 8 you can have two apps open side by side.  This is called snapped view.  To do this, open one app that you want to have "snapped", then click on the top of it and drag the app to either the left or right side.  Then you can select on the larger content area and get back to the start menu to open another app.  This is a really cool feature for some types of apps, but for others it is pretty useless.


Well, good luck using Windows 8.  Give it time, it took me a month to completely adjust to the new interface.


Thursday, October 18, 2012

Get Client IP Address in JBoss AS 7


Recently I was trying to figure out how to get the ip address of the calling client using JBoss AS 7.  I found a few examples that have basically the following code.

 import javax.servlet.http.*;

   @GET
   @Path("/")
   @Produces("text/xml")
public String login(@QueryParam("user") String user,
@QueryParam("password") String password,
@Context HttpServletRequest req) {
{
String ipAddress=req.getRemoteAddr();
        userLogin(user, password, ipAddress);
}

They key is to use the @Context annotation to get an HttpServletRequest.  Then you can just call getRemoteAddr().

Now, I tried this and I kept getting compilation errors.  I for some reason assumed that all of the jar's that JBoss used would be added to the classpath of eclipse when I installed the JBoss Tools.  Well, I guess they were not.  So, all I had to do was go to the project properties, then select Java Build Path, then select the Libraries tab and the jboss-servlet-api_3.0_spec-1.0.0.Final.jar to the project.
This jar is located at <JBOSS-INSTALL>\modules\javax\servlet\api\main, so for me on windows it was at C:\jboss-as-7.1.1.Final\modules\javax\servlet\api\main

That's it!