Disadvantages of using scriptlet tags on JSP for managing DOM structure

Posted By : Manish Gupta | 31-Oct-2017

Disadvantages of using scriptlet tag for business logic on jsp

JSP(Java Server Pages) technology undoubtedly provides a simplified, fast way to create the dynamic view for the web application. It does enables the rapid development 

of web applications that are server- and platform independent. But, in in real life, the JSP technology is to be used only for the view part of your web applications. 

All the business logic and the calculation must be done on the servlets or Business layers in your application.

The scriptlet tags provided by JSP technology should not be used to embed your business logic and then rendering the view. This is because of the following 

 

disadvantages it leads to.

1. No Code Reusability: Using the scriplet tags on JSP reduces the code reusability as if done so than view will be binded to that scriplet tags.

2. Poor structure of JSP page: Scriptlet tags if used on JSP page for view management does result in a structure of code that is difficult to understand and interpret.

3. Reduced readability of html code: Understanding the HTML of the final view gets complex.

4. Increases efforts to understand the JSP: Because view is dependent on the conditions defined in the scriplet tags, it do takes time to understand the JSP.

5. Prone to exception and hence no view at all: If any exception occurs on the JSP because of business logic, there will be no view at all.

 

 

Alternative to achieve the dynamic view of your application:

To overcome the above mentioned diadvantages, we use jquery to manage the view and bind the data as per the requirement that we can get from the ajax calls. Once the 

required data is available with us, we can bind it to the correct element of the html using the jquery selectors. 

Using jquery is easy to use and it helps in maintaining the structure of the view(JSP). It also helps in understanding the DOM structure and it takes less time for 

co-workers to understand the code written by you. 

-------------------------------

Thanks.

------------------------------

 

 

 

About Author

Author Image
Manish Gupta

Manish is a Java Developer with hands on experience in Core Java, JSP, Spring framework, JavaScript, JQuery, HTML, CSS, and SQL/PL-SQL. Tools used: Eclipse, Netbeans, DBeaver, Oracle SQL Developer, Toad, MS SQL Server. He is a keen learner and technology

Request for Proposal

Name is required

Comment is required

Sending message..