Results 1 to 8 of 8
  1. #1
    bpladna is offline Member
    Join Date
    Jun 2015
    Posts
    5
    Rep Power
    0

    Default #if statement returning #ttps instead of https

    When this statement is evaluated and the else is true, it returns #ttps instead of https. Example below.

    #if($example=="/One")https://test.com/goto/this/anchor#$someObject.substring(1)#elseif($example=="/Two")https://test.com/goto/that/anchor#$someObject.substring(1)#end

    I have tried numerous solutions such as {} around elseif, using #end#if, spacing after #elseif, ( after the first #if and ) before the #end

    If anyone can help, I would appreciate it very much.

    Thank you

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,993
    Rep Power
    8

    Default Re: #if statement returning #ttps instead of https

    substring(1) means everything from the second character up to the end. That would effectively cut off the first character.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: #if statement returning #ttps instead of https

    Yes but it is cutting of the first character of the templated data rather then velocity invoking a method substring() on a variable $someObject.

    Does the $someObject variable even exist? Is it a String object?

    EDIT:

    actually after a quick peek in some stackoverflow questions I think this is the proper way to output model content in a template:

    Java Code:
    #if($example=="/One")https://test.com/goto/this/anchor#${someObject.substring(1)}#elseif($example=="/Two")https://test.com/goto/that/anchor#${someObject.substring(1)}#end
    So $someObject.substring(1) became ${someObject.substring(1)}

    http://stackoverflow.com/questions/1...den-html-input
    Last edited by gimbal2; 06-12-2015 at 04:18 PM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    bpladna is offline Member
    Join Date
    Jun 2015
    Posts
    5
    Rep Power
    0

    Default Re: #if statement returning #ttps instead of https

    Thank you for the replies. I will give it a try.

  5. #5
    bpladna is offline Member
    Join Date
    Jun 2015
    Posts
    5
    Rep Power
    0

    Default Re: #if statement returning #ttps instead of https

    Interesting find. When I try ${someObject.substring(1)}, it doesn't work but when I try {$someObject.substring(1)} it works BUT, it is displaying {} around the result. I do not use {} around the next someObject and it works. I have multiple entries similar to this and I do not use {} at all around the ones after if or elseif and they work. It is strange. Bascally I only had to use {} one time and now all the entries work. Any ideas?

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: #if statement returning #ttps instead of https

    Sorry, your explanation does not paint a clear picture.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    bpladna is offline Member
    Join Date
    Jun 2015
    Posts
    5
    Rep Power
    0

    Default Re: #if statement returning #ttps instead of https

    Ignore all that. I tried putting {} but it still has the same issue. When I do {$someObject.substring(1)} it retruns the url but the variable returns literally with {} around it. I dont use the {} around the $someObject.substring(1) that is after the elseif and that URL displays properly now. So, now I need to figure out why the one after the IF is not working properly now. Any thoughts?

  8. #8
    bpladna is offline Member
    Join Date
    Jun 2015
    Posts
    5
    Rep Power
    0

    Default Re: #if statement returning #ttps instead of https

    It looks like i figured it out. The # in my URL appeared to be interpreted incorrectly. I created a variable that equals # and now it appears to work. Thank you for the help.

Similar Threads

  1. SSL/HTTPS Certificate Help
    By dlopez in forum Advanced Java
    Replies: 2
    Last Post: 06-20-2012, 05:13 PM
  2. HTTPS Certificates
    By cjtjamandra in forum Advanced Java
    Replies: 0
    Last Post: 09-28-2011, 12:49 PM
  3. https
    By jamesEFDS in forum Networking
    Replies: 3
    Last Post: 07-13-2011, 04:32 PM
  4. Https and authentication
    By vinaykutsa in forum Networking
    Replies: 0
    Last Post: 03-10-2011, 03:48 AM
  5. JDK 1.3 with HTTPS
    By sriram in forum Advanced Java
    Replies: 2
    Last Post: 01-21-2008, 10:51 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •