Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8527117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:27:54+00:00 2026-06-11T08:27:54+00:00

I am trying to use JSoup with ColdFusion to clean up some HTML but

  • 0

I am trying to use JSoup with ColdFusion to clean up some HTML but am encountering the following error:

The addTags method was not found. Either there are no methods with the specified method name and argument types or the addTags method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.

My code is as follows:

<cfset jsoup = createObject('java','org.jsoup.Jsoup')>
<cfset Whitelist = createObject("java", "org.jsoup.safety.Whitelist")>

<cfset parsedhtml = jsoup.parse(form.contentrichtext)> 
<cfset post = parsedhtml.body().html()>
<cfset post = jsoup.clean(post, Whitelist.none().addTags("span"))>

I have dumped out the Whitelist object and the add Tags method is present. If I remove the addTags() method and use one of the standard JSoup Whitelists such as basic(), none() or relaxed() then the code runs perfectly. As far as I can see from other online examples this is the correct syntax for using the addTags() method.

I am fairly new to using Java objects within ColdFusion so this has got me stumped.

Any help would be greatly appreciated.

Thanks,
Michael.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:27:56+00:00Added an answer on June 11, 2026 at 8:27 am

    The addTags method expects an array of strings, not just a single string. Put the value into an array first:

    <!--- create a CF array then cast it as type string[] --->  
    <cfset tagArray = javacast("string[]", ["span"]) >
    <cfset post = jsoup.clean(post, Whitelist.none().addTags( tagArray ))>
    

    Edit:

    As far as I can see from other online examples this is the correct
    syntax

    To clarify, that is the correct syntax – for java. In java you can pass in a variable number of arguments using either an array or this syntax: addTags("tag1", "tag2", ...). However, CF only supports the array syntax. So if you cfdump the java object, you will see square brackets after the class name, which indicates the argument is an array:

         method:  addTags( java.lang.String[] )  // array of strings
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jsoup in order to parse a html file. It was
I'm trying to use JSoup in my android app to parse a certain website.
I'm trying to make getJSON to use JSONP object, but I can't figure out
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I'm trying to use JSoup 1.6.0 with my Android application and it throws a
I'm trying to use jsoup to login to a site and then scrape information,
I am trying to clean HTML text and to extract plain text from it
I'm trying to use jQuery-jsonp plugin with jQuery Deferred Objects but I'm having no
I am trying to solve the following problem. Assume I have a HTML file
I've been trying to figure out how to use jsonp in my situation, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.