#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Shimonoseki / JAPAN
    Posts
    58
    Rep Power
    12

    inserting a querystring variable into <!--include--> URL parth.. kinda tricky?


    This is not working
    Code:
    activelang=Request.QueryString("lang")
    .
    some code
    .
    Response.Write " <!--#include virtual='/SIFS/" & activelang & "/welcome.txt' -->"
    this is not working too...
    Code:
    activelang=Request.QueryString("lang")
    .
    some code
    .
    <!--#include virtual='/SIFS/<%= activelang %>/welcome.txt' -->
    Is there any trick will do the job ?
    Thanks for any replies...
    Sweet smell of a great sorrow lies over the land. Plumes of smoke rise, merge into the leaden sky. A man lies and dreams of green fields and rivers, but awakes to a morning with no reason for waking. He's haunted by the memory of lost paradise. In his youth or dream, he can't be precise. He's chained forever to a world that's departed. It's not enough, it's not enough.
    Gilmour
  2. #2
  3. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    I think the problem is that all the include files are processed first then all the code is executed. So I bet that your include is just being writtten to the html document and is not being processed.

    I did some quick research and came up with an idea for you. I've never tried this and it only works in ASP 3.0 but I think you need to use the Response.Execute() function. If I understand correctly <!-- #include... --> is the old way of doing things. You should now be using Response.Execute() to use include files. I've never used the Execute method or tried to create dynamic inlcude files but here is my stab at it anyway.

    Code:
    activelang=Request.QueryString("lang")
    .
    some code
    .
    Response.Execute("/SIFS/" & activelang & "/welcome.txt")
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Shimonoseki / JAPAN
    Posts
    58
    Rep Power
    12
    Thanks a million for your time defjam

    I will try. If it doesn't works, I will have to do it the hard way:
    Code:
    If activelang="jp" then
    <!--include this-->
    elseif activelang="en" then
    <!--include that-->
    End if
    etc..
    Sweet smell of a great sorrow lies over the land. Plumes of smoke rise, merge into the leaden sky. A man lies and dreams of green fields and rivers, but awakes to a morning with no reason for waking. He's haunted by the memory of lost paradise. In his youth or dream, he can't be precise. He's chained forever to a world that's departed. It's not enough, it's not enough.
    Gilmour
  6. #4
  7. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    If your going to have more than 2 options a select case may be a better option. Another plus is that I find it easier to update.

    Code:
    activelang=lCase(Request.QueryString("lang")) 'convert to lower case
    
    Select Case activelang
      Case "jp"
        <!-- #include... -->
      Case "en"
        <!-- #include... -->
      Case "blah"
        <!-- #include... -->
      Case "gibberish"
        <!-- #include... -->
      Case Else 'default
        <!-- #include... -->
    End Select
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Shimonoseki / JAPAN
    Posts
    58
    Rep Power
    12
    Done!
    It is working.
    But with one little difference.
    It is not Response.Execute but Server.Execute
    Thanks.
    Sweet smell of a great sorrow lies over the land. Plumes of smoke rise, merge into the leaden sky. A man lies and dreams of green fields and rivers, but awakes to a morning with no reason for waking. He's haunted by the memory of lost paradise. In his youth or dream, he can't be precise. He's chained forever to a world that's departed. It's not enough, it's not enough.
    Gilmour
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Shimonoseki / JAPAN
    Posts
    58
    Rep Power
    12
    Update:

    Server.Execute is little different. It won't include any variable from the original page. I mean:
    Code:
     page1.asp
    name="Burak"
    Server.Execute("page2.asp")
    ---------------
    page2.asp
    Response.Write name
    This code will return "" because page2.asp will be executed in itself while <!--include--> can recognize all variables in original page. I can actually send a querystring like Server.Execute("page2.asp?name=Burak") but I am getting 'invalid URL' error. According to microsoft, this is a known bug and will be fixed.
    Just FYI...
    Sweet smell of a great sorrow lies over the land. Plumes of smoke rise, merge into the leaden sky. A man lies and dreams of green fields and rivers, but awakes to a morning with no reason for waking. He's haunted by the memory of lost paradise. In his youth or dream, he can't be precise. He's chained forever to a world that's departed. It's not enough, it's not enough.
    Gilmour
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    NJ
    Posts
    428
    Rep Power
    16

    Word of caution


    I wouldn't recommend having a querysting variable alone be inserted into the include statement. I think your just opening up a can of worms security wise allowing users to include any file they want via the querystring. I know your thinking security through obscurity and all that but still its not a good idea. The PHP forum has a list thread about security notes for programming with php, which are general hints for being safe, and most of them apply to asp as well. It maybe be good for you to read that article. It really makes you think. Also, at the very least, do some sort of verification that the the activelang variable does hold values that you expect. Either a regular expression, or a case statement. At least this way it isn't open ended.

IMN logo majestic logo threadwatch logo seochat tools logo