• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Duplicate code

 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64994
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If youare using a JSP 2 engine, look up the concept of a prelude.
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,
I'm using a JSP 2 engine only.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gosh!!
I missed out the <url-pattern>
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I changed my web.xml to this,
But still it doesn't work
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it working now...Thanks Bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic