Sitemesh 2.4.2 + FreeMarker + Struts 2.1.8 integration plugin!


I have created a replacement on the 2.1.8 branch that is due to be committed on the Struts 2.2.0 release down the road.  The plugin works well with the 2.1.8 source code and lets you use the Freemarker filter in web.xml like you did before without problems:


    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>org.apache.struts2.sitemesh.FreeMarkerPageFilter</filter-class>
    </filter>

The plugin is marked as a 2.2.0 snapshot, but is built on the 2.1.8 source.

 Download it here: struts2-sitemesh-plugin-2.2.0-SNAPSHOT.jar

 
 
 
 

Passing memories.


I am once again in Munich, and am staying in my favorite hotel near where my Oma lived. I am here saying goodbye to her dear spirit, as burial maintenance is so expensive that she could only be buried for 8 years.

She was a chain smoker, and I was so allergic that I found it best and most polite to excuse myself to run most every day. I would explore this road and that path, and came across one of my most romantic sights on one of my runs. So today I threw on my shoes, and went running through some old paths by where my grandmothers home was. It was a cute place that overlooked a large wheat field that when ripe would sway under the wind and look like waves of a great pale ocean. I loved it as she did, for that vista was the reason for her home there.

A few large cranes and many many new homes are now built upon the field I came to love so much. My heart just dropped. The smells of ripe wheat are all gone. A little stand of trees that defiantly stood in the middle of the field that I used to love to run through has also vanished, and is now the location of a small grocery.

This is just a very subtle reminder that all things precious always seem to be temporal as well. I suppose they must be in order to be precious. So eventually all the wheat fields and stands of trees must become a side road to someone else's home, or even become a convenience store parking lot. But I... I will never forget how the fields rocked under the summer breeze, and the earthy smells while running through them will always live in my heart.

 
 
 
 

Last Day of Body Cleanse


It has been a very interesting journey. I am in my final day of the cleanse, and it has been really eye-opening.

I played games at a friends home here in Texas where they have cats... no allergies at all. From what I can tell, all of my allergies are gone and have been absent for the past two weeks. I am very happy about this.

I am feeling a lot better. My joints and muscles feel better, my appetite and hunger are much more regular, I am becoming more toned... all in all, an amazing change. I wonder what another month or so would do. I think I will take part of this dietary change with me after tomorrow.

I hate to say it, but this actually works!

What was the hardest part. Eating out... anywhere. Even a vegan cafe leaves little to eat. A place like Chili's or Mexican... no options at all. Anything (if possible) that you would eat must be a special order. Also, it is right in the middle of party season, and the potluck spreads from my friends would break your heart.

Was/is it worth it? I would say yes. Our nation tends to eat lots and lots of crap. If anything, this diet will make really clear just how terrible (or good) your eating habits are. There was a time when the food pyramid included at most 3 meals a week containing meat (not fish). Most people eat meat at every meal now (or close to it). How many salads are in your diet? Salads and such should comprise the majority of your meals. I think you get the picture... the awareness alone of your regular diet is worth this cleanse. You will become so much smarter about food! The funny thing is that you will be compelled to. I constantly check websites to confirm that something was bad for me. Corn bad? Yep! But corn is a vegetable... and baked corn chips must be good... nope! You get the picture.

On another and more personal note, this dietary cleanse has led me to make some choices that really have changed my life. While it wasn't easy, it was a very worthwhile pursuit!

 
 
 
 

Chile Volcano Erupts With Ash and Lightning


Volcano

Chile's Chaitén volcano spewed lava and blasted ash more than 12 miles (19 kilometers) into the sky on Tuesday May 6th, 2008, prompting a total evacuation of the provincial capital and other settlements.

President Michelle Bachelet interrupted a speech in the capital to announce that "the volcano is exploding, so a total evacuation of the town of Chaitén has been ordered."

The mingling of lightning and ash seen above may be a "dirty thunderstorm."

The little-understood storms may be sparked when rock fragments, ash, and ice particles in the plume collide to produce static chargesjust as ice particles collide to create charge in regular thunderstorms.

I am absolutely amazed by this picture. The pyroclastic cloud containing all that silica has a side effect of creating stunning bolts of lightning. Never have I imagined such a thing! Just when you thought that natural phenomena cannot surprise you anymore, something so dramatically stunning such as this photo really can humble you.

 
 
 
 

Second week of the body cleanse...


Well, it has been a few more days than two weeks. I have some very interesting news, but I want to first say that all those people who say that the first week is the hardest... they lie. Each day is in fact a bit harder! However, I am starting to see some huge benefits that I will discuss now.

Foremost, amazingly, my allergies are gone. Yep, gone. I held kittens yesterday without flinching. Normally, kittens would lay me right out... done... check please. Sad, because I love animals too. However, I visited friends who do have cats that I am terribly allergic to, and not a single reaction. Is this a gift from taking on this spiritual cleanse, or is this an indication of all the crap that is in our normal foods. I don't know the answer to that yet. Also, mowed the grass with no problems. Seriously, for those of you who know me, this is amazing. I had allergy shots every day for the first 8 years of my life, and I dose up whenever I am around high-allergen animals like cats.

Second, my sensitivity to the energies around me is growing very strong. Each day I am amazed at what is going on now. I am very pleased about this one!

Third, I feel healthier. I've lost a little bit of weight, am eating constantly, and still have my normal exercise routine. However my skin is softer and smoother. I have scars on my feet from martial arts past that are finally healing after 15 years. There are so many more things, it is amazing!

So these factors are making the fast something more than just a test, or endurance, or a cleanse. It is truly miraculous. Now don't get me wrong... I already have a date with a tex-mex restaurant in Houston the day my fast ends. Oh yeah, a big margarita and a chicken burrito are in my future. However, if I see any reduction of these benefits, I may try and normally be much more mindful as to what I put in my mouth. Who knows...

I want to also note that these benefits didn't even begin to show until just around the two week mark. I was pretty much demoralized on day 12, seeing no benefits except being crabby. Also I made the mistake of purchasing my favorite candies on halloween... and almost wept as I handed them out to the kids :)

 
 
 
 

Stages of Marriage and Change


A few days ago, I had a great discussion with a number of my friends regarding the stages of marriage, loss, and change. Basically, there was an assertion put forward that marriage and change incur the same cyclic feelings as loss does. The 5 stages of loss (and by extension marriage and change) are as follows:

Stage 1 - Denial
Stage 2 - Anger 
Stage 3 - Bargaining
Stage 4 - Depression
Stage 5 - Acceptance

The idea is that for both men and women (although a few people at the table felt that only men do this and women magically do something different), there is a denial about the change that happens when one enters a marriage or incurs change. The denial is based on the idea that you can have both your former "single" life, and your "married" life as well. I will personally add that there was a lot of deep sorrow placed on the term "married life" and joy placed in the "single life" definition. So you think you have both the same freedoms of being single and the benefits of being married without any of the responsibilities that go along with marriage. This is the first stage.

Exiting the first stage, you have to recognize your responsibilities and face up to them. No you can't do that anymore because it is your turn to make dinner on those days. No you can't spend an evening with your friends because you have to be at home to watch the kids. You get the idea. This eventually leads to the perception of suffocating or loss of control, and that brews anger. When you are at this point, apparently you are now in stage 2.

Stage three was the most fun to listen to... bargaining. Husband says "I'm going out with my friends tomorrow." Wife says "Not if you want sex this week". This is apparently the act of bargaining, and from what I can tell most of my friends aren't very good at it. Mostly, they laugh about it as if it was futile effort of the past, share requests and compromises and how those didn't quite pan out the way they want. I love the fact that the most common bargaining chips tend to be sex and the shared use of a motor vehicles. In any case, I have determined that if I have many of my married friends around, it is always fun to discuss how bargaining works in their relationships!

Depression sets in after you recognize the futility of bargaining. Something has to go, and until you let you you will remain as a "Stage 4" patient. I have seen a few friends go through this, not just in marriage, but in so many relationships. Usually the signs show up as sighs randomly spread out across a conversation, even if the conversation is a fun one. Depression is a sad topic to discuss, as bringing up what was stressing a stage 4 patient still makes them sigh, even if they have progressed through this stage.

Finally, when you resolve the conflict and embrace the change, you move into the last stage... acceptance. You recognize the loss and adopt your new life. When moving into the acceptance phase, many people choose divorce instead of remaining in the marriage. The question when entering stage 5 is: "Do you fight or get divorced?" Either way, you have embraced the changes and adopted your new life.

So my real thoughts here is that any change can lead up to this. With an ideal partner, you should be able to talk about and embrace these changes... work through them as a team. Why not? While you cannot sync with each other or agree on every issue, why can't you talk through things in the bargaining phase. Perhaps both of you bend a little bit. It seems that doesn't seem to be happening very often nowadays. Note that I am far from experienced in these fields, and very much are an idealist. I have been in relationships for years and I don't remember ever having to rectify my single life with my relationship life in any significant depressing way. When I parted from the relationships, it was usually because our futures were not on the same path, or they do not really understand me. Perhaps this is the point... when you have made that choice, and there is no easy way out, then perhaps it is a very different game indeed.

Shortly after having this discussion, I went to a party and talked to two friends who celebrated 24 years of marriage with several kids produced from the relationship. He plays guitar backwards and makes crazy songs... is very driven. She balances him, being much more relaxed, a very good listener, and has no problem working a farm. Their energies really sync. I am sure they have been through some challenges. Still, I saw something here. I don't think these phases were so bad because what they gained from the relationship far outweighed what was lost. They were happier and more fulfilled, and as a result they embraced the changes that were presented to them.

Now, since this will be on my website, and if you happen to be the spouse of anyone who think I was talking with, then I want to absolutely positively assert that your husband or wife wasn't present, and if they were (which you know they were not), then they did nothing but shake their head and stay out of the conversation.

 
 
 
 

First week of the body cleanse...


At first glance this just seems insane to me, but I am also seeing some benefits, as well as warning signs. I don't think I would recommend this kind of cleanse to anyone without consulting a doctor first. To give you an idea, I will cover a number of things that I am noticing...

First, an intense craving for mexican food. Sure I am craving Phở every day... but that is not abnormal for me. However, I have a dream now of a bean and chicken chimichanga with refried beans and rice (including tomatoes of course), and a big ass margarita... ideally that says "Big Ass Margarita" on the glass. This craving extends to pretty much everything that comes in a box, bag, or any food which could be artfully presented at a potluck gathering.

I am also noticing dramatic changes in my weight. I could lose 15 pounds, and I was hoping to do that over a year. I decided to weigh myself twice a day to make certain that I don't lose more than 5 pounds in the month. However, in the first two days I gained weight... 3 pounds to be certain... so I skipped stepping on the scale for a few days because I wanted to not focus on the weight. However, I weighed myself two days ago (day 6) and not only lost the 3 pounds, but an additional 8 pounds too. Holy crap! For the last two days I have been eating as much as I can stand... yep, still losing about 2 pounds a day. So I am really freaking out, and trying to eat more frequent meals, etc..

The first week was terrible for my energy. Now that I am over the first week, I am excited to say that it appears that the first week was the easy one. I was running about 20 miles a week, and now I am somewhere around 10-12. My blood sugar just drops through the floor and my feet just stop. I am fine for about an hour or so after each meal, and then suddenly not so fine.

I'm also a bit more reclusive. Being social seems a bit of a task... energy? Since I am very outgoing, this just puts me into the normal category I believe. Still, these next weeks will be a wonder!

The positives? Spiritually, I am feeling more and less focused at the same time. My mind seems more open, more aware, and yet all over the map. Today, I feel more focused... like my mind is being sharpened and honed as a tool. Physically... not so much.

 
 
 
 

Anti-Inflammatory Food Choices


Try and eat only organically grown foods as they reportedly have 2-5x more nutrients and it will decrease exposure to pesticides. There is no restriction on the amount of food you can eat. The foods listed are only examples of foods to eat. Try to compose meals of approximately 40% carbohydrates, 30% protein and 30% healthy fats. Try to eat any 1 food no more than 5 times a week. Plan your meals ahead of time and try to find at least 10 recipes you enjoy.

Steamed vegetables:

• The primary reason for using steamed vegetables is that steaming improves the utilization or the availability of the food nutrients allowing the GI mucosa to repair itself. Use minimal raw vegetables except as a salad. Include at least 1 green vegetable daily.
• Eat a variety of any and all vegetables (except tomatoes, potatoes) that you can tolerate. It is best to try and eat mostly the lower carbohydrate (3, 6%) vegetables. For example:
3% - asparagus, bean sprouts, beet greens, broccoli, red & green cabbage, cauliflower, celery, Swiss chard, cucumber, endive, lettuce (red, green, romaine), mustard greens, parsley, radish, spinach, watercress.
6% - string beans, beets, Bok Choy, brussel sprouts, chives, collards, eggplant, kale, kohlrabi, leeks, onion, parsley, red pepper, pumpkin, rutabagas, turnip, zucchini.
15% - artichoke, parsnip, green peas, squash, carrot.
20+% - yam.
Add your favorite spices to enhance the taste of these vegetables.

Grains:

• Eat one to two cups of cooked grains per day of those you tolerate, unless you have indications of high insulin levels such as overweight, high blood pressure, high cholesterol or diabetes.
• Allowed grains include: amaranth, barley, buckwheat, millet, oatmeal, quinoa, basmati or brown rice, rye, teff.
• Other grain foods that may be eaten are rice crisps and Wasa crackers.

Legumes:

• Eat a variety of any legumes that you are able to tolerate. Soak for 48-72 hours and cook slowly: split peas, lentils, kidney beans, pinto beans, fermented soy (tempeh or miso), mung beans, garbanzo beans, aduki & azuki beans.

Fish:

• Poach, bake, steam, or broil deep-sea ocean (vs. farmed) fish (cod, haddock, halibut, mackerel, sardines, summer flounder, wild Pacific salmon) is preferred - no shellfish (shrimp, lobster, crab, clam).
Chicken/ Turkey:
• Eat only the meat & not the skin of free – range or organically grown chicken/turkey. Bake, broil, steam.

Meat:
• Lamb, buffalo, venison, elk are OK

Fruit
:
• Eat only 1 or 2 pieces of practically any fruit except citrus. If possible, it is preferred to eat the fruit baked (such as a baked apple or pear). Like the vegetables, try to eat mostly the low carbohydrate fruits. For example:
3% - cantaloupe, rhubarb, strawberries, melons
6% - apricot, blackberries, cranberries, papaya, peach, plum, raspberries, kiwi
15% - apple, blueberries, cherries, grapes, mango, pear, pineapple, pomegranate
20+% - banana, figs, prunes

Sweeteners:

• Occasionally maple syrup, rice syrup, barley syrup, raw honey or stevia – use ONLY with meals.
• Absolutely no sugar, NutraSweet, or any other sweetener is allowed.

Seeds and Nuts:

• Grind flax, pumpkin, sesame or sunflower seeds and add to steamed vegetables, cooked grains etc. You may also eat nut and seed butters – almond, brazil, cashew, sesame etc.

Butter/Oils
:
• For butter, mix together 1 pound of organic butter and 1 cup of extra virgin olive oil (from a new dark jar). Whip at room temperature and store in the refrigerator.
• Use extra virgin olive oil for all other situations requiring oil.

Spices:

• To add a delightful flavor to your food choices, add whatever spices you enjoy.

To Drink
:
• A MINIMUM of 6 to 8 glasses of spring, bottled, filtered or reverse-osmosis filtered water every day. Drink 1/2 your body weight in ounces of water daily. Sip the water, try to drink 1 glass per hour. A few drops of chlorophyll will add a pleasant taste. NO distilled water.
• Small amounts of soy, rice, or oat milk are allowed ONLY on cooked grains or in cooking.

For the time being, avoid the following foods:

all animal milks
all animal cheeses
all corn products
commercial eggs (organic OK)
potatoes – red or white
tomatoes
all wheat products including
breads
white flour
citrus fruits
all fruit juices
all dried fruit
peanuts/ peanut butter
any processed food
fried foods
meat - red meat (beef, pork)
all caffeinated teas, coffee
alcohol

Anti-Inflammatory Diet


Inflammation is a set of symptoms that includes pain, swelling, heat and redness of an affected organ or tissue. It's the way the body's immune system responds to attack, infection or injury. The immune system response to an unsatisfactory diet can lead to chronic inflammation of various body systems, leading to conditions such as arthritis and various auto-immune diseases like lupus. Recently there has been an increased focus on diets and lifestyle plans that seek to end the cycle of inflammation and its deleterious consequences.

Foods that fight inflammation

A typical anti-inflammatory diet focuses on creating anti-inflammatory prostaglandins instead of pro-inflammatory prostaglandins. Prostaglandins are hormones produced by the body whose function is to regulate the body's inflammatory response. We produce these hormones from the fats we ingest as part of our diets, and it's been found that different types of fat result in the production of different types of prostaglandins. One key part of an effective anti-inflammatory diet is to ingest only ""good"" fats and avoid ""bad"" ones.

1. The good fats - ones you should eat

Omega-3 Fatty Acid, found mainly in cold-water fish like mackerel, salmon, sardines, anchovies, and herring. The oils of wild-caught fish contain a significantly higher proportion of Omega-3 than the oils of farm-raised fish. Other sources of Omega-3 are nuts and seeds. These vegetable sources include walnuts, brazil nuts, and almonds along with pumpkin and sunflower seeds. 

For further information on what to look for when buying fish see the following article from TheDietChannel: Fish Safety & Buying Guide.

2. The bad fats - ones you should avoid

Polyunsaturated and partly hydrogenated fats and oils lead to the synthesis of pro-inflammatory prostaglandins and so should be eliminated from the diet. It's not easy to avoid these ""bad fats,"" as they are found in most processed foods. Trans-fats should be strictly avoided; this can be done by using olive oil instead of margarine and shortening. Olive oil contains Omega-9 essential fatty acids which work in concert with Omega-3 EFAs and increase its benefits to the body.

3. Other foods good for preventing inflammation

A number of other foods have anti-inflammatory qualities and should be part of the diet. These foods contain high levels of <vitamin A, vitamin C, and vitamin E:
Fruits and Vegetables -- blackberries, strawberries, raspberries, kiwi fruit, peaches, mango, cantaloupe melon, apples, carrots, squash, sweet potato, spinach, kale, collard greens, broccoli, cabbage, and Brussels sprouts.
• Grains -- lentils, chick peas (garbanzo beans), brown rice, wheat germ, and non-instant oatmeal.

Two other essential components of an effective anti-inflammatory diet are Ginger and Turmeric, known since ancient times for their ameliorative properties.


Feel the benefit of the Anti-Inflammatory Diet


People who have suffered any of the wide range of symptoms linked with inflammation can feel real benefits by switching to an anti-inflammatory diet. Among the positive changes you may experience are:

• Reduction in joint pain due to Arthritis.
• Improved digestion.
• Lower blood cholesterol and triglyceride levels.
• Relief from symptoms of Depression and Bi-polar Disorder.


An anti-inflammatory diet follows principles of good nutrition by reducing intake of unhealthy fats, and increasing consumption of healthy fats, fruits, vegetables, and whole grains. Even if you don't have any overt inflammation, the diet itself is healthy and will do its part to keep you healthy, too.

 
 
 
 

Beginning a 30-day body cleanse. No inflammatory foods.


I was told in a journey that I needed to do a 30 day detox/cleanse of my body to clean away toxins and help energy flow more smoothly. I normally am very against any radical change in ones diet, because it tends to set your body into "starvation mode" and the long term effects are horrid. Now I find myself facing this test, and I hope to share information later along this journey that will help people decide whether it is something they wish to pursue or not. It turns out that there is a lot to be said for reducing foods that are inflammatory. Sad thing is that most everything I enjoy has something inflammatory in it. I pretty much cannot eat out anywhere because almost everything has wheat or gluten in it! What I suspect in the end is that I will say "don't do it... run away". But we will see!

Initially, my research led to the following facts about what common foods are inflammatory:

- all dairy (damn no cheese)
- all wheat and wheat products (including gluten) (damn no fresh bread) 
- all meat (damn no chicken)
- some fishes (damn no salmon)
- all nightshades (like potatoes, tomatoes, and eggplant)... no potatoes!?! WTF, what did they ever do?

But now I am formally getting a list together while I happily eat an apple (I bought a few honey crisps as a treat to start things out right). I found some nifty websites indicating a whole range of foods... what is and isn't inflammatory, and began a plan on what to include and exclude. I found a very good site about inflammation factors (IF) and IF data, which promised a list of everything I could eat. It looks legit, so here is the link...

http://www.nutritiondata.com/help/inflammation#example

I read some bits about how Omega-3 foods are really good, and fatty and processed foods bad. Cool! About two minutes later I noticed apples on the inflammatory list! I spit out the rest of the apple, cursed in a guttural language that would make a Klingon proud, and began to read more carefully... No sugar! Ack, that means no alcohol... yep! I can eat salmon, but only if it is wild (apparently farm raised salmon is just about the worst thing you can do with mercury anyways). Raw jalapeno peppers... um, yum? Almonds and peanuts are good, but Oatmeal is right out (which I bought a whole bunch of on sale lately).

Okay, this is starting to suck real quick! However, I know 2 people who don't eat any of these things because they suffer serious joint pain and also debilitating effects if they even touch a nightshade, so I know there is some truth behind this terribly stupid idea.

Without further ado, here is a sample of IF data for a whole number of foods. For the record, negative is bad, and positive is good.

 

Sample IF Ratings
FoodServing SizeRating
Almond, dry roasted1 ounce56
Apple1 medium-62
Bagel, plain1 bagel-186
Bread, mixed grain1 slice-33
Broccoli, boiled1/2 cup73
Butter1 tbsp-45
Cantaloupe1 cup21
Carrot, raw1 large71
Cheddar cheese1 oz-26
Chicken breast, roasted (no skin)3 oz-14
Corn flakes1 cup-182
Cottage cheese, 1% fat1/2 cup9
Egg, whole1 large-43
French fries, fast food1 medium-336
Green beans, boiled1/2 cup15
Ground turkey, cooked3 oz-60
Ice cream, chocolate1/2 cup-127
Jalapeno pepper, raw1 pepper55
Milk, low-fat (1%)1 cup-33
Oatmeal cookie1 small-76
Olive oil1 tbsp73
Pasta shells, cooked1/2 cup-55
Peanuts, dry roasted1/4 cup14
Pork tenderloin, broiled or grilled3 oz13
Salmon, Atlantic (farm-raised)3 oz-180
Salmon, Atlantic (wild)3 oz493
Spinach, raw1 cup (loosely packed)80
Strawberries1 cup, sliced28
Tortilla chips, plain1 oz-91

 

 
 
 
 

Building Struts 2 on Mac OS X with Maven using mvn install


When trying to build Struts 2 on Mac OS X (I'm using 10.4.8) you might get an error like:
 class="codeContent" class="codeContent"[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

----------
1) com.sun:tools:jar:1.5.0

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=com.sun -DartifactId=tools \
          -Dversion=1.5.0 -Dpackaging=jar -Dfile=/path/to/file

  Path to dependency: 
        1) org.apache.struts:struts2-core:jar:2.0.3-SNAPSHOT
        2) org.apache.struts:struts-annotations:jar:1.0-SNAPSHOT
        3) com.sun:tools:jar:1.5.0

----------
1 required artifact is missing.

for artifact: 
  org.apache.struts:struts2-core:jar:2.0.3-SNAPSHOT

from the specified remote repositories:
  Maven Snapshots (http://snapshots.maven.codehaus.org/maven2/),
  central (http://repo1.maven.org/maven2),
  opensymphony (http://maven.opensymphony.com),
  apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository),
  snapshots-maven-codehaus (http://snapshots.maven.codehaus.org/maven2)
The problem is that there is no tools.jar on Mac OS X. The analog for tools.jar on Mac OS X is classes.jar. A quick fix to allow the build to continue is to change the sun.jdk dependency in a pom.xml. For this, I edited the
 class="commentblock"pom.xml
located in
 class="commentblock"~/.m2/repository/org/apache/struts/struts-annotations/1.0-SNAPSHOT/
 class="codeContent"    <dependency>
      <groupId>com.sun</groupId>
      <artifactId>tools</artifactId>
      <version>1.5.0</version>
      <scope>system</scope>
      <!-- This line doesn't work on a Mac: <systemPath>${java.home}/../lib/tools.jar</systemPath> -->
      <systemPath>${java.home}/../Classes/classes.jar</systemPath>

    </dependency>

Troubleshooting and other Tips

OutOfMemoryError

If you are getting OutOfMemoryError exceptions when attempting a full build of Mule you may try increasing the max heap and the PermGen space sizes. Either export a MAVEN_OPTS variable in your shell or add it to the original mvn script.

 class="codeContent"MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m

or edit your bash shell

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"
 
 
 
 

How to force download of an attachment/application using JSP.


Many of you guys out there would have experienced the problems associated with the browser interpreting whether to
download an application/attachment or open up in the same browser instance. Whenever microsoft's IE encounters a href tag
pointing to an excel/doc/ppt or any other tool whose plugins have been installed on the client, it opens the attachment
in the same instance of the browser. Hence if a user has to save the file then he has to be smart enuff to click on file
--> save as from the menu and then save to his hard disk.

But most web-applications are designed for ease and not keeping the user's technical skill or knowledge in view. Hence
when a user clicks on a href(which might say click to download pdf version) pointing to say mydownloadable.pdf, what
happens is the pdf downloads the file to his temporary internet files and shows it in the browser.

The code snippet below shows how one can force download a file/app/attachment to the user irrespective of whether the
user has a necessary plugin or not. Even the name of the downloaded file can be specified dynamically.

<!--contents of download.jsp-->
<%@ page import="java.util.*,java.io.*"%>
<!--Assumes that file name is in the request objects query Parameter -->

<%
//read the file name.

File f = new File ("c:/fop/mypdf/" + request.getParameter("file") );
//set the content type(can be excel/word/powerpoint etc..)
response.setContentType ("application/pdf");
//set the header and also the Name by which user will be prompted to save
response.setHeader ("Content-Disposition", "attachment;
filename=\"LicenseAgreement.pdf\"");

//get the file name
String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
//OPen an input stream to the file and post the file contents thru the
//servlet output stream to the client m/c

InputStream in = new FileInputStream(f);
ServletOutputStream outs = response.getOutputStream();
int bit = 256; int i = 0;
try {
while ((bit) >= 0) {
bit = in.read();
outs.write(bit);
}
//System.out.println("" +bit);

} catch (IOException ioe) {
ioe.printStackTrace(System.out);
}
// System.out.println( "\n" + i + " byt
// es sent.");
// System.out.println( "\n" + f.length(
// ) + " bytes sent.");
outs.flush();
outs.close();
in.close();
%>




Hope you find this useful...

Happy Programming!!!

Backing up a server with Rsync


Tips on using the rsync command. rsync performs incremental filesystem transfers, allowing filesystem duplication or snap shotting. Alternatives to rsync on Unix systems include cp -r, pipes between tar commands, or unison.

rsync behaves differently if the source directory has a trailing slash. Study and learn the difference between the following two commands before moving on. Use the -n option to rsync when testing to preview what would happen.

$ rsync -n -av /tmp .
$ rsync -n -av /tmp/ .

Permissions & Ownership

Normally, the -a option can be used to perfectly mirror the files. However, if the target filesystem does not support permissions, a different set of options should be used to avoid warnings from rsync. To synchronize data to a USB drive with a FAT filesystem, I use the -rlt options.

#!/bin/sh
RSYNC="rsync --size-only --delete --delete-excluded --exclude-from=~/.rsync/exclude -rlt"

TARGET=$1
$RSYNC ~/Talks $TARGET

mkdir -p $TARGET/backup/repository
$RSYNC ~/share/repository/ $TARGET/backup/repository

A ~/.rsync/exclude can be used to list common file patterns to ignore, for example .DS_Store files on Mac OS X.

$ cat ~/.rsync/exclude
.DS_Store
.FBCLockFolder

Secure Network Transfers

Set the -e option of rsync to use ssh instead of rsh when copying to a remote system. While ssh is slower than rsh, the data being transfered will be encrypted.

$ rsync -e 'ssh -ax' -avz example.org:/tmp .

If speed is a concern, use a weaker encryption option to ssh.

$ rsync -e 'ssh -c blowfish -ax' -avz example.org:/tmp .

The -ax options to ssh disable Secure Shell (SSH) agent and X11 forwarding, which are not needed by rsync. Also consider setting -o ClearAllForwardings to ssh, to prevent possible automatic port forwardings. For more information on options to OpenSSH, see ssh(1) and ssh_config(5).

Timeout

To avoid stalls, set the --timeout option, though not low enough that rsync times out before it can build the filesystem differences in memory. In rare cases I have seen rsync not exit, so for unattended runs like filesystem snapshots I set the --timeout option to ensure the command will eventually quit.

Backups with rsync and SSH

Notes on how to configure periodic rsync runs over SSH. Filesystem duplication or snap shotting scripts may set the following up in different ways; the method outlined here mirrors the home directory of the user running the script from a client system to a backup server.

  1. Setup a SSH key pair without password.
  2. A public key without a password allows unattended periodic backups. The public key should be locked down to only allow backups on the system the rsync is done to. These notes are for OpenSSH as of version 3.8.

    On the system the rsync backup script is run on (client in these notes), create a SSH keypair.

    client$ ssh-keygen -N '' -C backup1 -t rsa -f ~/.ssh/backup

  3. Configure public key on backup server.
  4. On the system the rsync backup script connects to (server in these notes), configure the public key. These notes cover OpenSSH; consult the manual if a different SSH implementation is being used. Details on common problems with OpenSSH public key authentication.

    client$ scp ~/.ssh/backup.pub server:.ssh

    server$ cd ~/.ssh
    server$ cat backup.pub >> authorized_keys
    server$ rm backup.pub

    For security, the authorized_keys file should be edited to only allow specific commands among other limitations. For more information, see sshd(8) and sshd_config(5). The command limitation to use can be determined by running the rsync with the -e 'ssh -v -v -v' option to see the exact command run on the server.

    The following example shows how to restrict a public key in the authorized_keys file to only run the specified command, along with other restrictions on the connection. The limitations must be listed on one line, prior to the lengthy public key data.

    command="rsync --server -v --timeout=999 --delete-excluded . backup/client",21B5;
    no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3Nza2026;

  5. Create the target backup directory on the server.
  6. rsync will not create the target directory ($HOME/backup/client) on the server; the target directory must be manually created.

    server$ mkdir -p ~/backup/client

  7. Create backup script dobackup.
  8. Use the example script linked to, and localize it as needed.

    To test the script, try prefixing the rsync call with echo to see what would be run, or add the -n option to rsync to see what it would copy.

  9. Configure a ~/.rsync/exclude file to list files not to backup.
  10. Cache files and other transitory data should be skipped. For information on how to exclude files, see EXCLUDE PATTERNS in rsync(1).

    $ cat ~/.rsync/exclude
    .DS_Store
    .mozilla/**/Cache
    *.o

  11. Run backup script via a crontab(5) entry.
  12. In addition to automatic runs, the script can be run manually from the command line.

    client$ crontab -l
    @daily $HOME/bin/dobackup

    client$ ~/bin/dobackup
    2026;

    Need to figure out simple locking to prevent an automated run from conflicting with a manual run.

Mac OS X & the Hierarchical File System (HFS)

Mac OS X 10.4 (Tiger) supports the -E option to rsync, which copies extended filesystem attributes.

On previous versions of OS X, compile rsync with the rsync+hfsmode patch. Note that rsync may have trouble with symbolic links (ownerships and permissions) and sockets (perhaps -gHlopqrtx instead of -a).

Linux/Mac OS X: Allow ssh access to server without requiring password.


1) Generate a new key (the -f command -f ~/.ssh/access gives it an optional name, -C allows for a comment):


xtian@desktop$ ssh-keygen -C commont_or_purpose -d

Generating public/private dsa key pair.
Enter file in which to save the key (/home/xtian/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/xtian/.ssh/id_dsa.
Your public key has been saved in /home/xtian/.ssh/id_dsa.pub.
The key fingerprint is:
33:3c:5c:41:98:1b:fc:f5:9e:69:56:2e:0b:f1:24:7f xtian@desktop

* The -d option specifies DSA keys (instead of RSA keys). The ssh v2 protocol uses DSA keys, and is widely regarded as more secure than v1.

* After entering the command, hit enter three times (to take the default filename, and to enter no passphrase.)

* Congratulations. Your public and private keys are now saved to ~/.ssh/id_dsa.pub and ~/.ssh/id_dsa, respectively.

2) Copy the key to your Web server:


xtian@desktop$ scp ~/.ssh/id_dsa.pub www.stonescape.net:.ssh/authorized_keys2

* At this point, if you've never used ssh from your OS X box before, you'll be prompted to verify the fingerprint of the server's key. Answering "yes" will save the server's fingerprint in a local cache. Should the fingerprint ever change, ssh (and scp) will sound an alarm, as this could be an indication of a man-in-the-middle attack in progress.

* You will be prompted for your password on the Web server. Enter it, and the key file will be copied.

3) Modify the key to your Web server:

xtian@desktop$ ssh stonescape.net
xtian@server$ cd .ssh
xtian@server$ cat id_dsa.pub >> authorized_keys2
xtian@server$ rm backup.pub
xtian@server$ exit

* You will be prompted for your password on the Web server.

4) Test the ssh key:


xtian@stonescape$ ssh www.stonescape.net
login: Mon Oct 29 10:58:32 2001 from desktop.stonescape.com xtian@server$

* It should log you in without a password. If not, check your work. Also check that your Web server allows public key exchange (it's on by default, and is rarely disabled. Check with your friendly local sysadmin if you're not sure.)

Restricting access to a .ssh key for a specific command


The following example shows how to restrict a public key in the authorized_keys (.ssh directory) file to only run the specified command, along with other restrictions on the connection. The limitations must be listed on one line, prior to the lengthy public key data.

command="rsync --server -v --timeout=999 --delete-excluded . backup/client",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3Nza…

 
 
 
 
 
 
Search Web Log

« August 2010
SunMonTueWedThuFriSat
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
    
       
Today