aspose file tools*
The moose likes JSP and the fly likes Duplicate code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Duplicate code" Watch "Duplicate code" New topic
Author

Duplicate code

Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Hi all,
I've these directives at the top of all my JSP pages(I've 5 JSP pages as of now)
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

These are caught by the Simian Analyser (identifies duplication in Java, C#, C, C++, COBOL, Ruby, JSP, ASP, HTML, XML, Visual Basic source code and even plain text files)as duplicate lines of code.How do i eliminate this?

Regards,
Srikkanth
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61199
    
  66

If youare using a JSP 2 engine, look up the concept of a prelude.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Bear,
I'm using a JSP 2 engine only.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61199
    
  66

Then you can add a declaration to the web.xml that will cause a file you specify as a prelude to be automaticvally invoked before each JSP. The file can contain your common declarations.

See the JSP specification for details.
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Hi Bear,
I added the following element to my web.xml



And my prelude.jspf looks like this



I also removed all the directives from the JSP's but it doesn't work.

P.S This is a Spring application,do i need to change some other thing,?
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Gosh!!
I missed out the <url-pattern>
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Hi all,

I changed my web.xml to this,
But still it doesn't work
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
I got it working now...Thanks Bear
 
 
subject: Duplicate code