Friday, February 22, 2008

Advantages and Disadvantages of Struts

Advantages of Struts

Centralized File-Based Configuration.
Rather than hard-coding information into Java programs, many Struts values are represented in XML or property files. This loose coupling means that many changes can be made without modifying or recompiling Java code, and that wholesale changes can be made by editing a single file.

Form Beans.
In JSP, you can use property="*" with jsp:setProperty to automatically populate a JavaBean component based on incoming request parameters.

Bean Tags.
Apache Struts provides a set of custom JSP tags (bean:write, in particular) that let you easily output the properties of JavaBeans components. Basically, these are concise and powerful variations of the standard jsp:useBean and jsp:getProperty tags.

HTML Tags.
Apache Struts provides a set of custom JSP tags to create HTML forms that are associated with JavaBeans components. This bean/form association serves two useful purposes:

  • It lets you get initial form-field values from Java objects.
  • It lets you redisplay forms with some or all previously entered values intact.

Form Field Validation.
Apache Struts has builtin capabilities for checking that form values are in the required format. If values are missing or in an improper format, the form can be automatically redisplayed with error messages and with the previously entered values maintained.
This validation can be performed on the server (in Java), or both on the server and on the client (in JavaScript).

Consistent Approach.
Struts encourages consistent use of MVC throughout your application.

Easy to learn and implement

Struts makes it easier to develop large web apps

Large user base

The dominant (by far) framework - developers available, advice
available, books, etc

Open Source.
Open source, freely usable
All components subclassable or replaceable!
Includes powerful JSP Tag libraries
Supported by third-party packages

With a controller, a Web application is a series of requests and
responses, as HTTP intended. The views request and an action responds
with another view. Ideally, your views become scriplet-free "JavaBean
Pages", that could be easily edited with a visual Java 2 Web editor (at
least as soon as we get one!).

Disadvantages of Struts

· Less Transparent.
With Struts applications, there is a lot more going on behind the scenes than with normal Java-based Web applications. As a result, Struts applications are:

  • Harder to understand
  • Harder to benchmark and optimize

· Rigid Approach.

The flip side of the benefit that Struts encourages a consistent approach to MVC is that Struts makes it difficult (but by no means impossible) to use other approaches.

Sometimes MVC is not needed. It depends on what your application is, how many people you will have working on it, and most importantly what the skill level is of the people coding your application.

You might be better off with PHP or just scriptlets rather that dealing with all of the theoretical benefits of MVC.

Compare JSF and Struts

Advantages of JSF (vs. Struts)
Custom components
JSF makes it relatively easy to combine complex GUIs into a single manageable component; Struts does not
Support for other display technologies
JSF is not limited to HTML and HTTP; Struts is
Access to beans by name
JSF lets you assign names to beans, then you refer to them by name in the forms. Struts have a complex process with several levels of indirection where you have to remember which form is the input for which action.
Expression language
The JSF expression language is more concise and powerful than the Struts bean:write tag.
This is less advantageous if using JSP 2.0 anyhow.
Simpler controller and bean definitions
JSF does not require your controller and bean classes to extend any particular parent class (e.g., Action) or use any particular method (e.g., execute). Struts does.
Simpler config file and overall structure
The faces-config.xml file is much easier to use than is the struts-config.xml file. In general, JSF is simpler.
More powerful potential tool support
The orientation around GUI controls and their handlers opens possibility of simple to use, drag-and-drop IDEs

Disadvantages of JSF (vs. Struts)

Established base and industry momentum
Struts has a large core of existing developers and momentum among both developers and IT managers; JSF does not.

Support for other display technologies
JSF is not limited to HTML and HTTP; Struts is

Confusion vs. file names
The actual pages used in JSF end in .jsp. But the URLs used end in .faces or .jsf. This causes many problems; in particular, in JSF

You cannot browse directories and click on links

It is hard to protect raw JSP pages from access

It is hard to refer to non-faces pages in faces-config.xml

Self-submit approach
With Struts, the form (blah.jsp) and the handler (blah.do) have different URLs; with JSF they are the same. Many developers find this clumsy.

Less current tool support
Struts is supported by many widely used IDEs; JSF is not (yet)

No equivalent to Tiles
Struts comes with a powerful page layout facility; JSF does not
But you can extract Tiles from Struts and use it with JSF

Much weaker automatic validation
Struts comes with validators for email address, credit card numbers, regular expressions, and more. JSF only comes with validators for missing values, length of input, and numbers in a given range.
But MyFaces has several powerful validators
Lack of client-side validation

Struts supports JavaScript-based form-field validation; JSF does not
Worse installation

JSF does not have equivalent of struts-blank to start with

POST only
JSF does not support GET, so you cannot bookmark results pages

Thursday, February 21, 2008

Advantages of Jpa over native hibernate

Jpa is the specification for persistence architecture in java and is implemented by various ORM providers like toplinks and hibernate.
JPA is not only annotations. There is also other differences, as configuration file named persistence.xml (should be placed in META-INF directory)
We can use hibernate in 3 modes:
  • core Hibernate
  • Hibernate with annotations
  • Hibernate as JPA provider

Hibernate as Jpa provider has certain advantages over other two...

It provides a standard, portable code. By portable, I mean we can change persistence provider without changing code! For example we can change Hibernate persistence into TopLink persistence without any modification Java files by just changing persistence.xml and jars.

Another advantage is possibility to use it with or without EJB, so you can use JPA on the JSE in the same way as on JEE.

But this approach has a disadvantage as well
Complex mappings cant be provided using jpa therefore we need to go back to native hibernate in that case..

Troubleshooting "My Computer" Opening Slowly on Windows XP

f "My Computer" takes a really long time to open on your computer, you are most likely experiencing a well-known issue where Windows hangs while trying to search for network folders and printers before displaying anything to you.

Follow the steps below:
1.Open up Folder Options from the Tools menu in Windows Explorer
2.Then choose the View tab
3.Uncheck the box for "Automatically search for network folders and printers", and close the dialog.
4.The changes should be immediate, and your problem should be gone.

Wednesday, February 20, 2008

Generate traffic on your website

Want to increase the no of hits you get on your site??Who doesnt get a high on seeing a huge number of hitcount on his website
Here are the few steps which can help u increase traffic on your site..
1. Submit you site in all safe search engines
2. Submit in all internet directories.
3. Get link back from other websites with identical content.
4. Go for offline advertising of your website.
5. Write articles in other sites and leave ur wwbsite's link therer.
6. Leave ur comments on other forums of related topics and ofcourse ur site's url:)
7. Bring your visitors back by creating a rss button.
8. Publicize your website on different social networking sites like scribd.com,delicious.com,orkut,facebook,indyarocks.com etc.

Earn money on Internet

Everyone now a days want to make a quick buck by spending not much of time and effort.
The BIG Giant Google provides you an opprtunity to do just dat.The only tools u need is just a lil bit of time to create a website of yours and if not dat you can create your blog,
register it on google adsense and hurray !!!your jobe is done.rest will be taken care by google.
Just make sure that ur site's content lures the visitors right away n dey keep cming back to ur site.So that traffic ur site generates is high n as n wen a visitor clicks on advertisement on ur website ,u get paid!!!!
As simple as that!!!!
If you do not know how to generate that traffic just read my post on the same..

Automation Testing using Selenium

Strategy for Automation of Test Cases


How automation is achieved using Selenium

1. Open the webpage for which automation needs to be done in Firefox Browser.
2. Open Selenium IDE.
3.To use Selenium Core, you need to make it available from the same web server as the application you want to test.So copy the selenium core into htdocs directory of your webserver
3. Some of the commands like clicking a link, typing in some textbox etc are generated automatically using recording mode of selenium.
4. Other commands are written manually using the IDE.
5. Save the test as html file.
6. Add the link for this html file in the file “ testSuite.html” present at location -selenium-core-0.8.2\tests\



Execution of test cases

1. Open the specific browser in which a test case needs to be executed.
2. Open the link-”http://selenium-core-0.8.2/core/TestRunner.html”
3. Select the desired test case.
4. Click the button-“execute selected test case”.
5. When the execution ends, the test cases which fail are highlighted in green color while the rest of the test cases are shown in green color.



Issues

1. Since XPath is being used for identifying modules in a webpage, even a slight modification in the page would require modifications in the tests.
2. Some of the test cases don’t work wit Safari.
3. Scheduling of the execution of test cases can’t be achieved using selenium core and selenium IDE since the links for the desired test cases need to be clicked manually in all the browsers.

Imp:
Scheduling of the execution of test cases
This can be achieved using Selenium RC but Seleniun RC doesn’t work with FireFox 2.0 and above

Can I have more than one struts-config.xml file

Yes we can have more than one struts-config.xml files for a single struts
application in condition.1. If we have more than one module in our application.
These are new features in Struts1.1



..............

.............





config





/WEB-INF/struts-config.xml









config/login







/WEB-INF/struts-config-login.xml





.............

.........



where default and login our two module.2. If we want to use more than one
struts-config.xml files to make our application simple .



..............

.............





config





/WEB-INF/struts-config.xml,/WEB-INF/struts-config-login.xml





.............

.........

Monday, February 18, 2008

Compare ActionErrors and ActionMessages

What is the difference between ActionErrors and ActionMessages

ActionMessages is the super class of ActionErrors.

n struts 1.0 to dispaly the errors, ActionError was used but struts1.1 that feature depricated by ActionMessage tag.

it will be generated like

main advantage of ActionMmessage tag is it does not force to write html tags in properties file .but ActionError object forces to write html tags.


Action Message :
Encapsulate the collection of message,these message are global, each message specified the particular bean property, these contain the key, which refers the resource bundle in database.

Action Error :Â This is a return type of the validate(),contain the collection of error messages, these message are reported by the validate() of the Action form
these message are global and represent the particular bean property,


Wednesday, February 6, 2008

Enable "Pin to Start Menu" for Folders in Windows Vista / XP

Manual Registry Hack

Open up regedit.exe through the start menu search box, and then browse down to the following key:

HKEY_CLASSES_ROOT\Folder\shellex\ContextMenuHandlers\

Once there, you'll need to create a new key called {a2a9545d-a0c2-42b4-9708-a0b2badd77c8} with no value.

If you want to disable this, just delete the key.



Add "Open with Notepad" to the Context Menu for All Files

Whenever u try to open a file of unknown extension, a pop up comes which makes u scroll down the list of applications and select one(which most of the times is notepad)So y not have the option jst on 1 single right click.Follow the steps n u'll have 1!!!

Manual Registry Hack

Open regedit.exe through the start menu search or run box, and then browse down to the following key:

HKEY_CLASSES_ROOT\*\shell


Right-click on "shell" and choose to create a new key, calling it "Open with Notepad". Create a new key below that one called "command". Double-click on the (Default) value in the right-hand pane and enter in the following:

notepad.exe %1

Now right-click on any file and you'll see the new entry.

Sunday, February 3, 2008

Remove applications from Start-up

Applications that start as soon as the pc boots up makes the boot process really slow.To remove applications from start up,Follow the given steps:
1.Type"msconfig" in run window
2.Click on start-up tab
3.Uncheck the checkbox against applications which you dont want to get started at boot time.