Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    JSP newbie Quick Syntax Check

    So I have just a couple simple JSP lines of code I need to right in order to dynamically set a file path. I'm familiar with PHP and have the following which I want to convert into JSP:

    Code:
    <?php $wa_path = "//" . $_SERVER['HTTP_HOST'] . "/path/filename"; ?>
    <script language="JavaScript" src="<?php echo $wa_path; ?>.js"></script>
    <noscript>
    	<img src="<?php echo $wa_path; ?>.gif?js=0" height="1" width="1" border="0" hspace="0" vspace="0" alt="">
    </noscript>
    Is the following a correct conversion to JSP syntax?

    Code:
    <%! String wa_path = "//" + request.getServerName() + "/path/filename"; %>
    <script language="JavaScript" src="<%! out.printIn ( wa_path ); %>.js"></script>
    <noscript>
    	<img src="<%! out.printIn ( wa_path ); %>.gif?js=0" height="1" width="1" border="0" hspace="0" vspace="0" alt="">
    </noscript>
    Thank you!

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    erase red part, notice blue part, then you should be close

    Code:
    <%! String wa_path = "//" + request.getServerName() + "/path/filename"; %>
    <script language="JavaScript" src="<%! out.printIn ( wa_path ); %>.js"></script>
    <noscript>
    	<img src="<%! = wa_path %>.gif?js=0" height="1" width="1" border="0" hspace="0" vspace="0" alt="">
    </noscript>
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #3
    New Coder
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts
    So would this be correct?...

    Code:
    <% String wa_path = "//" + request.getServerName() + "/path/filename"; %>
    <script language="JavaScript" src="<% = wa_path %>.js"></script>
    <noscript>
    	<img src="<% = wa_path %>.gif?js=0" height="1" width="1" border="0" hspace="0" vspace="0" alt="">
    </noscript>

  • #4
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    could be, but be careful about "/" google for:

    Code:
    System.getProperty("file.separator")
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search


  •  

    Posting Permissions

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