Incorrect Invoke-WebRequest cookie path handling?

While trying to access a printer's web interface to automate something I noticed an oddity in the way Powershell handles cookies. What happens is that I send my login info to a server side script, and that script then sets a cookie in the response without
a "Path" header.
Powershell then saves that cookie to the path of the login script itself
And will not resend it for any future requests that go to a URI other than "login.cgi", which makes any future actions depending on a login fail.
Now, by http://www.ietf.org/rfc/rfc2109.txt the default value of the path should be: "the path of the request URL that generated the Set-Cookie response, up to, but not including, the right-most
/" so in fact the directory the page is in, not the page itself.
I checked the behaviour of IE and Chrome, and that is in fact how they are handling it, they attach that cookie to the path "/" instead of "/login.cgi"
Is this a bug in Powershell or am I doing something wrong? This is in Windows 7 / Powershell 3.0 / .NET 4.5.1
By the way, so far I can work around this problem by manually copying the cookie, but it shouldn't technically be necessary.
$s.Cookies.Add("http://10.0.11.251/", $s.Cookies.GetCookies("http://10.0.11.251/login.cgi"))

Hi,
I am facing the same issue. Have you able to resolved this???

Similar Messages

  • Invoke-WebRequest - Double byte characters issue in windows 8.1

    I try write a powershell script to download a file from web server but failed. The path have double byte characters.
    I could run in Windows server 2012 and 2012 R2 successfully, but fail in Windows 8 & 8.1
    Do there any difference below Windows server and client powershell?
    Region and setting are same in Windows 2012 & Windows 8
    Script as below
    Invoke-WebRequest -Uri " http://hostname/m/%E9%...../......./...../xxx.jpg"

    Security settings are one possible cause of this.
    Since we don't have your URL we cannot reproduce this. 
    It is "different". Using "difference" had me confused for qa bit.  I though you were trying to figure out the difference between two things.
    Use:
    $wc=New-Object System.Net.WebClient
    $ws.DownloadFile($url,'c:\file.jpg')
    You will see less issues and it is faster.
    ¯\_(ツ)_/¯

  • Enter into web page recursively using invoke-webrequest

    This is how I authorize to web page using Invoke-WebRequest command right now:
    $web = Invoke-WebRequest https://mypage/ -SessionVariable gos
    $forms = $web.Forms[0]
    $forms.Fields["username"] = "[email protected]"
    $forms.Fields["password"] = "pass"
    $web_invoke = Invoke-WebRequest -Uri ("https://mypage" + $forms.Action) -WebSession $matt -Method Post -Body 
    $web_invoke.StatusDescription
    Thing is that I have to login once again when I logged into first webpage to reach another service.
    I have traced logid_ID and passsword_ID as well as button that will transfer me to the needed page.
    How can I combine these two logins in one script?

    Hi Kirillpashkov,
    If you want to sign in web service, the example below is for your reference, which could sign in to the Facebook web service:
    # Sends a sign-in request by running the Invoke-WebRequest cmdlet. The command specifies a value of "fb" for the SessionVariable parameter, and saves the results in the $r variable.
    $r=Invoke-WebRequest http://www.facebook.com/login.php -SessionVariable fb
    # Use the session variable that you created in Example 1. Output displays values for Headers, Cookies, Credentials, etc.
    $fb
    # Gets the first form in the Forms property of the HTTP response object in the $r variable, and saves it in the $form variable.
    $form = $r.Forms[0]
    # Pipes the form properties that are stored in the $forms variable into the Format-List cmdlet, to display those properties in a list.
    $form | Format-List
    # Displays the keys and values in the hash table (dictionary) object in the Fields property of the form.
    $form.fields
    # The next two commands populate the values of the "email" and "pass" keys of the hash table in the Fields property of the form. Of course, you can replace the email and password with values that you want to use.
    $form.Fields["email"] = "[email protected]"
    $form.Fields["pass"] = "P@ssw0rd"
    # The final command uses the Invoke-WebRequest cmdlet to sign in to the Facebook web service.
    $r=Invoke-WebRequest -Uri ("https://www.facebook.com" + $form.Action) -WebSession $fb -Method POST -Body $form.Fields
    Refer to:
    accept a cookie while using Invoke-WebRequest
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang

  • Invoke-webrequest doesn't comeout when posting data on server with -InFile flag and file size is more than 820 MB

    I am using invoke-webrequest command to load a file on server with POST command, and the file does get loaded. However the command hangs in console until I hit enter.
    Here's what I m executing: 
    Invoke-RestMethod -Uri $url -Method POST -ContentType $ContentType -Headers $headerHash -InFile $filePath  -TimeoutSec $timeOut
    I am running powershell 3.0 on win2k12.
    I ran the command with Verbose on, and it ask for confirmation to run the command as below. However when I provided -confirm:$true, invoke-webrequest suggests that there's no confirm command. I am not sure how to proceed.
    Confirm
    Continue with this operation?
    [Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"):

    Hi Varun,
    Is there any update ?
    Best Regards,
    Elton Ji
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] .

  • How to get all records using Invoke-webrequest?/Why Invoke-webrequest returns only first 2000 Records?

    invoke-webrequest content returning only 2000 records though it has around 4000 records in web api.
    The same url if I give in excel oData Data feed I am getting all the records.
    See the below script
    Script:
    $QueryResult= (Invoke-WebRequest -Uri $ODataURI -UseDefaultCredentials)
    [xml]$xmlResult=$QueryResult.content
    foreach($obj in $xmlResult.feed.entry.content.properties)
    $Name=$obj.Name;
    $IsAvail=$obj.isAvail.'#text';
    $PGroup=$obj.PGroup
    I am exporting the above result as a CSV file and my CSV file contains only 2000 records. 
    But,  $xmlResult.feed.Count --> it Shows 4000 Records.
    The same Odata url if I give in excel oData Data feed I am getting all the 4000 records.
    So Please help me how can I get all the records using power shell.
    Thanks
    A Pathfinder..
    JoSwa
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"
    Best Online Journal

    Hi Jo Swa(K.P.Elayaraja)-MCP,
    Would you please also post code which is used to export the records?
    In addition, to use the cmdlet invoke-RestMethod to work on ODate feeds, please refer to this article:
    Interacting with TechEd NA 2012 Schedule using PowerShell v3
    I hope this helps.

  • Motion path handles disappeared

    I've been working in After Effects for a little while now and am having some of my motion path handles not appear when they should. I'm working on a slideshow and they seem to appear for all of my other pictures. What I do is go in between the start and end point of a path and move my picture away from the main (straight) motion path I created which usually creates a new keyframe on my timeline and inserts a point on my motion path with two handles I can adjust to make the path curved. This time it just creates the point on the motion path and keyframe, but doesn't allow me to make the path curved. It's really strange and has happened to me before. The way I solved it earlier was to remove the point where it wasn't working and insert a new one, and it would magically turn on, but that doesn't seem to work now.
    I've only been able to find one other person that had a similar problem online, which was solved by going to view---->view options and enabling 'view handles'. This didn't solve my problem so I figured I would ask on here. Thanks in advance for the help.

    That worked, although it's a few extra steps that I shouldn't have to take (and haven't prior to this). I held down alt by mistake at first and it only gave me one handle, but if I just tap alt and then click--->drag away from the point, it does provide me with a handle in each direction, which is what I was ultimately needing. Here is a screenshot of that layer although it's pretty standard.
    When I selected a keyframe that was in between the beginning and end of the motion path, pressed G, and then hit alt it does exactly what I want it to, but usually it adds the handles automatically, and want it to always. This extra step is very annoying because I'm dealing with a lot of motion paths and plan to in the future as well.

  • Can't show content of Invoke-WebRequest in Unicode

    I am trying to get Japanese web pages through  Invoke-WebRequest but the contents get garbled in Console.
    PS> $JP_MSSITE = Invoke-WebRequest http://www.microsoft.co.jp
    PS> $JP_MSSITE.ParsedHtml.title
    a?\a?¬a??a??a? ̄a?-a??a??a??a??Microsoft Japan: a??a??a??a?|a?§a?¢, a?aa?3a?ca??a?3, a?1a??a??a??a??a?ca?3, a?μa??a??a??, a?≫a?-a?\a?aa??a?£, a?€a?|a?3a?-a??a??, a?¢a??a??a??a??a??, a??a??a??a?1a?¨a?μa??a??a?1
    PS>
    http://www.microsoft.co.jp is encoded in UTF8.
    The tile has "日本マイクロソフト..." which should be "97e6e6a5ac9c83e3e39ea48282e3e3af.."  in UTF8 bytes.
    $JP_MSSITE.ParsedHtml is not even in Unicode(UTF-16) which should be "65e5672c30de30a430af30ed30bd30d530c8.." for "日本マイクロソフト..."
    PS > [Convert]::ToString([Convert]::ToByte($JP_MSSITE.ParsedHtml.title[0]),16)
    e6
    PS > [Convert]::ToString([Convert]::ToByte($JP_MSSITE.ParsedHtml.title[1]),16)
    97
    PS > [Convert]::ToString([Convert]::ToByte($JP_MSSITE.ParsedHtml.title[2]),16)
    a5
    PS > [Convert]::ToString([Convert]::ToByte($JP_MSSITE.ParsedHtml.title[3]),16)
    e6
    What am I doing wrong

    Hi,
    It's a bit of a roundabout way of doing it but you can convert the page to bytes and then back in to text using the [text.encoding] accelerator:
    $JP_MSSITE = Invoke-WebRequest -ContentType "text/xml;charset=utf8" http://www.microsoft.co.jp
    $con = $JP_MSSITE.ParsedHtml.title
    $la = [system.text.encoding]::UTF8.GetBytes($con)
    [text.encoding]::Unicode.GetString($la)
    Produces:
    ꛃ韂ꗂꛃ鳂곂ꏃ菂黂ꏃ苂꓂ꏃ苂꿂ꏃ菂귂ꏃ苂뷂ꏃ菂闂ꏃ菂裂ꋃ铂苂楍牣獯景⁴慊慰㩮쌠슣슂쎽슣슃쎕슣슃쎈슣슂쎦슣슂쎧슣슂Ⲣ쌠슣슂쎪슣슃쎳슣슃쎩슣슂쎤슣슃ⲳ쌠슣슂쎹슣슃쎞슣슃쎼슣슃쎈슣슃쎕슣슂쎩슣슃ⲳ쌠슣슂쎵슣슃쎝슣슃쎼슣슃Ⲉ쌠슣슂쎻슣슂쎭슣슃쎥슣슃쎪슣슃쎆슣슂ⲣ쌠슣슃쎀슣슂쎦슣슃쎳슣슃쎭슣슃쎼슣슃ⲉ쌠슣슂쎢슣슃
    쎃슣슃쎗슣슃쎇슣슃쎼슣슃Ⲉ쌠슣슃쎇슣슃쎐슣슂쎤슣슂쎹슣슁쎨슣슂쎵슣슃쎼슣슃쎓슣슂
    It might need tweaking a bit to get exactly what you are after though.

  • Need help about Invoke-Webrequest and Invoke-RestMethod commandlets

    Invoke-webrequest content returning only 2000 records though it has around 4000 records in web api.
    If I give the same uri in excel oData Data feed I am getting all the records.
    Invoke-Restmethod also returning partial data from web api.
    Regards,
    Purna.

    Hi Purna,
    If you want to get the complete webpage content with powershell, please post the detailed information, like the queried url and the missing part of the webpage content you want to get.
    This example can get the detailed information of the webpage:
    Invoke-WebRequest http://mitpress.mit.edu/sites/default/files/titles/content/sicm/book-Z-H-51.html |
    select -expand images |
    select -expand src |
    foreach { start-bitstransfer $("http://mitpress.mit.edu/sites/default/files/titles/content/sicm/{0}" -f $_) C:\Users\Public\Downloads}
    Reference from:
    invoke-webrequest to get complete web page with images
    I hope this helps.

  • Restore snap-to-grid behaviour for path handles

    Hi,
    one of the new features in AI CC 2014 is path handles ignoring any grid. However, when one wants to construct C2-contious joins between seperate objects, precise control over the handle position is needed. I do a lot of icon and sprite art, and there it is imperative that curves from differnent objects flow exactly the same to create a smoth transition between individual pieces.
    How can one restore the ability of handles to snap to the grid like in previous versions of AI?
    Reagrds,
    Chris

    First of all, let's just hope Adobe fixes this issue in the next version. My workaround:
    1. Turn on Snap to Grid and the Grid and using Guides create your own grid. Tedious work, but handles actually still snap to the intersection of Guides.
    2. In the Preference panel, choose your Guides color to match the Grid color. This way you won't notice the difference.
    3. Turn off the Grid but leave Snap to Grid on for easy anchor placement.
    4. Name the layer you did this on 'Grid' or something. Do not lock this layer, otherwise this improvised 'handle snapping feature' won't work.
    5. Create a new layer on top of your 'Grid' layer. This new layer will be the first layer to work on.
    6. Save this file as a template to do your linework on.
    Keep in mind that the 'Grid' layer isn't locked, so you could accidentally drag a Guide out of place...
    Hope this helps!

  • Type on a Path handle stuck

    I created a line and used the Type on a Path tool to add text to the line. While I was adding the text I realized I needed the line to be longer. I pulled the handle to make the line longer, but it leaves the text path the shorter length. I grabbed the text path handle to make it the same length as the line, but it won't expand. I can make the path shorter, but not longer. It's acting as if it doesn't realize the line got longer and so it stops at the original line length's end point. Is there a setting that is causing this issue or just a bug? Usually when this happens I end up making a new path and pasting the text onto it because I can't figure out what's going on.
    Mac OSX 10.5.4
    InDesign CS3 5.0.4

    I don't seem to be able to reproduce the problem. It's often easier, I find, to manipulat type on a path using the direct select tool.
    You might want to try replacing your preferences.

  • Unable to submit form on web page using Invoke-WebRequest

    Looking to automate the Web search on HP's website by serial number to get the warranty data.  I am able to successfully get back the web page, and I can populate the fields in the form. However, when I submit the POST, I don't seem to get back any
    data.
    Please look at the below script and tell me what I'm doing wrong. I am following the FACEBOOK "Example 2" from the Get-Help in PowerShell 3.0.
    $Serial = "CND1076GST"
    $Url = "http://h20566.www2.hp.com/portal/site/hpsc/public/wc/home/"
    $r = Invoke-WebRequest -Uri $Url -SessionVariable HP
    If ($r.StatusDescription -eq "OK" ) {
    Write-Host $r.StatusDescription
    $HP
    $form = $r.Forms.Item("wcFormDataItem")
    $form.Fields["serialNumber0"] = $Serial
    $r2 = Invoke-WebRequest -Uri ($Url + $form.Action) -WebSession $HP -Method POST -Body $form.Fields
    $r2.Content | Out-File c:\temp\test.htm -Force
    Write-Host $r2.StatusDescription
    } Else {
    Write-Host $r.StatusDescription
    Levi Stevens | Technical Consultant Dell Services

    This is how easy it is to lookup the same data from Dell.
    $GUID = "cac8daa8-6699-466b-a3d3-f07e571fba1f"
    $AppName = "Dell Warranty"
    $ServiceTag = "5LCQSY1"
    $WebProxy=New-WebServiceProxy -Uri http://xserv.dell.com/services/assetservice.asmx
    $WarrantyInformation=$WebProxy.GetAssetInformation($GUID,"Dell Warranty",$ServiceTag)
    $WarrantyInformation | Select-Object -ExpandProperty Entitlements
    Levi Stevens | Technical Consultant Dell Services

  • Setting cookie path for JSESSIONID cookie for admin console

              We've run into a strange problem with the JSESSIONID cookie created for the weblogic
              console application clashing with the JSESSIONID cookie created for our application.
              We've set the path to application JSESSIONID cookie but have been unable to set
              the cookie path for the console application JSESSIONID cookie.
              Anyone know how to do this?
              Thanks,
              Mark
              

    Create a JAAS Authentication Entry in the Server configuration.
    This should then appear in the drop-down when specifying your DataSource.

  • Invoke-WebRequest loginform

    Hi everybody.
    I know it's a bit out of scope, but i thought that maybe someone had an idea anyway :)
    I have an Ruckus 7341 AP. I would like through powershell to login and pull some information about connected clients. Then I thought i could use Invoke-Webrequest for that the same way i have done with many other things. But when i try it keeps getting
    me the login page. Here's what i tried:
    $result = Invoke-WebRequest -Uri "http://192.168.1.2"
    $result.Forms[0].Fields.'login-username' = "super"
    $result.Forms[0].Fields.password = "*******"
    Invoke-WebRequest "http://192.168.1.2/forms/doLogin" -SessionVariable th -Body $result.Forms[0] -Method Post
    $data = Invoke-WebRequest -Uri "https://192.168.1.2/index.asp" -WebSession $th
    Any thoghts?

    Hi,
    Please try below code to signin a wen page, we should modify the name the elements according to the wenpage you use:
    $url = "http://192.168.1.2" 
    $username="Your_username" 
    $password="Your_password" 
    $ie = New-Object -com internetexplorer.application; 
    $ie.visible = $true; 
    $ie.navigate($url); 
    while ($ie.Busy -eq $true) 
        Start-Sleep -Milliseconds 1000; 
    $ie.Document.getElementById("User").value = $username 
    $ie.Document.getElementByID("Passwd").value=$password 
    $ie.Document.getElementById("signin").Click();
    Regards,
    Yan Li
    Regards, Yan Li
    Thanks for the reply Yan.
    I get an error:
    Property 'Value' cannot be found on this object; make sure it exists and is settable.
    At line:1 char:1
    + $ie.Document.getElementById("user").Value = 'super'
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound

  • Invoke-WebRequest with JSP forms

    Hi everyone,
    I am a newbie with PowerShell struggling to write a script that posts information to a JSP Web application.
    My script should be divided in two parts : 
    ########### The first should authenticate to the admin page (the form bellow)
    <form name="loginoath" id="loginoath" action="../servlet/UserRequestServlet" method="post" autocomplete="off">
    <input type="hidden" name="action"
        value="auth">
    <input type="hidden" name="authtype" id="authtype"
        value="oath">
    <input type="hidden" name="authformat"
        value="pwd">
    <input type="hidden" name="opensess"
        value="true">
    <input type="hidden" name="version"
        value="3.0">
    <input type="hidden" name="forwardtype"
        value="relativeurl">
    <input type="hidden" name="successurl" value="/adminportal/index.jsp">
    <input type="hidden" name="errorurl" value="/adminportal/login_oath.jsp">
        <tr valign="middle" class="display_row" id='authoption'>
            <td class="form_label">
                <span class="help_spot" onMouseOver="loadHelp('Select\x20\x3Cb\x3EPassword\x3C\x2Fb\x3E\x20to\x20log\x20in\x20with\x20your\x20user\x20ID\x20and\x20password\x20only.\x3Cbr\x3E\x3Cbr\x3ESelect\x20\x3Cb\x3EOTP\x3C\x2Fb\x3E\x20to\x20log\x20in\x20with\x20your\x20user\x20ID,\x20password,\x20and\x20a\x20one\x2Dtime\x20password\x20\x28OTP\x29\x20generated\x20from\x20your\x20device.')">
                    Authenticate by:
                </span>
            </td>
            <td class="form_field_cell">
                <input type="radio" name="authByOTP" id="authByOTP" value="yes" checked onclick="onChangeAuth()"> OTP&nbsp;
                <input type="radio" name="authByOTP" id="authByOTP" value="no"  onclick="onChangeAuth()" > Password&nbsp;
            </td>
        </tr>
        <tr valign="middle">
            <td class="form_label">
            <span class="help_spot" onMouseOver="loadHelp('Enter\x20the\x20user\x20ID\x20that\x20you\x20want\x20to\x20log\x20in\x20with.\x3Cbr\x3E\x3Cbr\x3EThe\x20user\x20ID\x20is\x20a\x20unique\x20alphanumeric\x20string\x20that\x20identifies\x20a\x20user.\x20It\x20is\x20assigned\x20when\x20the\x20user\x20record\x20is\x20created.')">
            User ID:</span>
            </td>
            <td>
                <input type="text" name="j_username" id="j_username" size="20" maxlength="50" tabindex="1" class="form_field">
            </td>
        </tr>
        <tr valign="middle">
            <td class="form_label">
            <span class="help_spot" onMouseOver="loadHelp('Enter\x20the\x20password\x20for\x20your\x20login\x20user\x20ID.\x3Cbr\x3E\x3Cbr\x3EThe\x20password\x20is\x20a\x20private\x20character\x20string\x20that\x20verifies\x20the\x20user\x20ID.\x20After\x20login,\x20this\x20password\x20can\x20be\x20changed.')">
            Password:</span>
            </td>
            <td>
                <input type="password" name="j_pin" id="j_pin" size="20" maxlength="50" tabindex="2" class="form_field">
            </td>
        </tr>
        <tr valign="middle" id="otp_section">
            <td class="form_label">
            <span class="help_spot" onMouseOver="loadHelp('Generate\x20a\x20one\x2Dtime\x20password\x20\x28OTP\x29\x20with\x20the\x20device\x20you\x20are\x20using\x20for\x20login,\x20and\x20enter\x20the\x20value\x20in\x20the\x20field.\x20Connected\x20devices\x20generate\x20and\x20enter\x20the\x20OTP\x20value\x20automatically\x20when\x20you\x20click\x20\x3Cb\x3EGet\x20OTP\x3C\x2Fb\x3E.\x3Cbr\x3E\x3Cbr\x3EConsult\x20your\x20device\x20documentation\x20for\x20instructions\x20on\x20how\x20to\x20generate\x20an\x20OTP.')">
            OTP:</span>
            </td>
            <td>
                <input type="text" name="j_password" id="j_password" size="20" maxlength="50" tabindex="3" class="form_field">
                <a href="javascript:gemalto.otpplugin.getOTPsAndPANForCustomButton();" class="form_button" onMouseOver="loadHelp('Click\x20this\x20button\x20to\x20generate\x20and\x20enter\x20the\x20one\x2Dtime\x20password\x20\x28OTP\x29\x20value\x20automatically\x20with\x20your\x20connected\x20device.\x3Cbr\x3E\x3Cbr\x3EBe\x20sure\x20that\x20your\x20device\x20is\x20plugged\x20in\x20and\x20connected\x20to\x20your\x20computer\x20before\x20trying\x20to\x20generate\x20the\x20OTP.')"/>Get
    OTP</a>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div class="form_separator"><img src="../img/spacer.gif"
                width="1" height="1"></div>
            </td>
        </tr>
        <tr valign="middle">
            <td colspan="2" align="center">
            <input type="submit" tabindex="4" id="login_button" name="submit" value="LOGIN" class="form_button" onMouseOver="loadHelp('When\x20you\x20have\x20entered\x20information\x20in\x20all\x20fields,\x20click\x20this\x20button\x20to\x20authenticate\x20your\x20user\x20ID\x20and\x20log\x20in\x20to\x20the\x20Customer\x20Care\x20Portal.')"
    onClick="return checkFields();">
            </td>
        </tr>
      </form>
    ########### The second should fill the form with new information and validate them (the form bellow)
    <form name="userform" action="user_migrate.jsp" method="POST" autocomplete="off">
        <tr>
            <td colspan="2" class="form_text" align="left">
                Fields marked with an asterisk <font color='red'><big>*</big></font> are required.
            </td>
        </tr>
        <tr valign="middle">
            <td class="form_label"><font color="red"><big>*</big></font>
            <span class="help_spot" onMouseOver="loadHelp('User\x20ID\x20field.\x20The\x20User\x20ID\x20is\x20a\x20unique\x20alphanumeric\x20string\x20chosen\x20to\x20identify\x20a\x20user.')">
            User ID:</span>
            </td>
            <td>
                <input type="text" name="userid" value="" size="26" class="form_field">
            </td>
        </tr>
           <tr id="pwdguideline">
                <td class="form_label"> &nbsp;</td>
            <td class="form_text" align="left">
                A valid password is case-sensitive and must: <br>&nbsp;-&nbsp; consists of 6 characters or more<br>&nbsp;-&nbsp; include at least 1 alphabetic character<br>&nbsp;-&nbsp;
    include at least 1 numeric character<br>&nbsp;-&nbsp; not include white space<br>
            </td>
        </tr>
            <input type="hidden" name="password" value=""/>
        <tr>
            <td class="form_label"><font color="red"><big>*</big></font>
            <span class="help_spot" onMouseOver="loadHelp('First\x20security\x20answer\x20field.\x20The\x20security\x20answers\x20are\x20answers\x20to\x20personal\x20questions\x20used\x20to\x20validate\x20a\x20user\x5C\x27s\x20identity\x20in\x20case\x20the\x20user\x20loses\x20his\x20or\x20her\x20password.')">
            What is your mother's maiden name?:</span>
            </td>
             <td>
                <input type="text" name="answer1" value="" size="26" class="form_field">
            </td>        
        </tr>
        <tr>
        <td class="form_label"><font color="red"><big>*</big></font>
            <span class="help_spot" onMouseOver="loadHelp('Second\x20security\x20answer\x20field.\x20The\x20security\x20answers\x20are\x20answers\x20to\x20personal\x20questions\x20used\x20to\x20validate\x20a\x20user\x5C\x27s\x20identity\x20in\x20case\x20the\x20user\x20loses\x20his\x20or\x20her\x20password.')">
            What is your date of birth?:<br>(yyyy-mm-dd)</span>
            </td>
             <td>
                <input type="text" name="answer2" value="" size="26" class="form_field">
            </td>  
        </tr>   
        <tr>
        <td class="form_label"><font color="red"><big>*</big></font>
            <span class="help_spot" onMouseOver="loadHelp('Role\x20field.\x20Refers\x20to\x20the\x20role\x20associated\x20with\x20the\x20user.\x20A\x20role\x20is\x20identified\x20by\x20its\x20unique\x20role\x20name\x20and\x20defines\x20what\x20functions\x20are\x20available\x20to\x20its\x20associated\x20users.')">
            Role:</span>
            </td>
              <td class="form_text">
                <select name="rolename" class="form_select" single>
                   <option value="Admin" >Admin</option>
                   <option value="Agent" >Agent</option>
                   <option value="Default" selected>Default</option>
                   <option value="Support" >Support</option>
                 </select>
                </td>
             </tr>
        <tr>
            <td class="form_label">
            <span class="help_spot"
                  onMouseOver="loadHelp('Sends\x20the\x20user\x20an\x20email\x20with\x20a\x20link\x20to\x20download\x20the\x20selected\x20application.\x20Email\x20must\x20be\x20filled\x20and\x20a\x20separate\x20mail\x20will\x20be\x20sent\x20per\x20application\x20selected.')">
            Initiate Token registration:</span>
            </td>
            <td class="form_field_cell">
                &nbsp;&nbsp;
                <input type="checkbox" name="initMobileapptokenReg" value="true" class="form_field_cell" >
                IDProve 300 Mobile
                &nbsp;&nbsp;
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <div class="form_separator"><img src="../img/spacer.gif"
                width="1" height="1"></div>
            </td>
        </tr>
        <tr valign="middle">
            <td colspan="2" align="center">
            <input type="submit" name="submituserform" value="MIGRATE" class="form_button" onMouseOver="loadHelp('Create\x20a\x20new\x20record.')" onClick="return validateForm()"
    >
            <input type="Reset" name="resetuserform" value="START OVER" class="form_button" onMouseOver="loadHelp('Reset\x20the\x20form.')">   
            </td>
        </tr>
        <input type="hidden" name="posting" value="true">
    </form>
    ############ Here is my Powershell Script
    [System.Net.ServicePointManager]::CheckCertificateRevocationList = $false;
    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true; };
    Add-Type @"
      using System.Net;
      using System.Security.Cryptography.X509Certificates;
      public class TrustAllCertsPolicy : ICertificatePolicy {
         public bool CheckValidationResult(
          ServicePoint srvPoint, X509Certificate certificate,
          WebRequest request, int certificateProblem) {
          return true;
    [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
    [System.Net.ServicePointManager]::CheckCertificateRevocationList = $false;
    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true; };
    # Authentication
    $url1 = 'https://localhost/login.jsp'
    $param1 = @{ authByOTP='no'; j_username='test'; j_pin='test' }
    Invoke-WebRequest -Uri $url1 -SessionVariable CurrentSession -Method Post -Body $param1 -ContentType "text/xml"
    # Registration
    $AccountName ="test2"
    $Reponse1 ="replyOne"
    $Reponse2 = "replyTwo"
    $Role ="Default"
    $IDProve ="False"
    $Post = "MIGRATE"
    $url2 = 'https://localhost/registration.jsp'
    $parametre2 = @{ userid=$AccountName; answer1=$Reponse1; answer2=$Reponse2; rolename=$Role;               'initMobileapptokenReg'=$IDProve; submituserform=$Post; }
    Invoke-WebRequest -Uri $url2 -SessionVariable CurrentSession -Method Post -Body $parametre2 -ContentType "text/xml"
    When I run it, I get this status
    StatusCode        : 200
    StatusDescription : OK
    Content           :
    But nothing happens when I check the result.
    I will be grateful if someone can help. Thanks in advance.
    Regards,
    Louban.

    Hi Louban,
    To run the cmdlet "Invoke-WebRequest" with .jsp file, the script is for your reference:
    # variables for the script
    $YellowLevel = 14
    $RedLevel = 7
    $SleepHours = 1
    # change window title
    $Host.UI.RawUI.WindowTitle = "QAS DB Expiry Checker"
    # loop indefinitely
    while($true){
    #get web page
    $Page = (Invoke-WebRequest "http://qaswebserver.rcmtech.co.uk:8080/proweb/test.jsp").Content # look for text on web page using regular expression
    if($Page -match "[0-9]+ days"){
    # get matching text string from full web page text
    $FullText = (Select-String -InputObject $Page -Pattern "[0-9]+ days").Matches.Value
    Write-Host (get-date),"QAS remaining: $FullText - " -NoNewline
    # get just the number of days
    $DaysString = (Select-String -InputObject $FullText -Pattern "[0-9]+").Matches.Value
    # convert number of days to integer to allow numeric matching operations, e.g. "greater than"
    $DaysInteger = [convert]::ToInt16($DaysString)
    # interrogate the number of days and set status based on what its value is
    switch($DaysInteger){
    {$_ -gt $YellowLevel} {
    Write-Host "Green" -ForegroundColor Green
    {($_ -le $YellowLevel) -and ($_ -gt $RedLevel)} {
    Write-Host "Yellow" -ForegroundColor Yellow
    {$_ -le $RedLevel} {
    Write-Host "Red" -ForegroundColor Red
    } else {
    # page did not contain expected text
    Write-Host "Error with page" -ForegroundColor Yellow
    # wait for specified time
    Start-Sleep -Seconds ($SleepHours * 60 * 60)
    Refer to:
    PowerShell: QuickAddress Pro data expiry checker
    If there is anything else regarding this matter, please feel free to post back.
    Best Regards,
    Anna Wang

  • JSF - Why getting wrong path Handling URLs in Facelets Templates

    Hi, I am trying to do a web application using JSF, Facelets in Netbeans 6.7. but I am having a problem:
    Why I am getting wrong path ?
    It is very simple, straight forward web application.
    When run, it shows the template-client.xhtml perfectly . The navigation menu is shows ok, but they don't work. However, if I enter in the browser address http://localhost:8080/test3/portal/products.jsf it goes perfect to the right page and the navigation between About, Products and Home works perfect. But once I click on Home, the menu start to give me errors. Looks like the path is wrong again.
    folders structure:
    test3My code:
    faces-config.xml:
    <?xml version='1.0' encoding='UTF-8'?>
    <!-- =========== FULL CONFIGURATION FILE ================================== -->
    <faces-config version="1.2"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
        <application>
            <view-handler>
                com.sun.facelets.FaceletViewHandler
            </view-handler>   
        </application>
    </faces-config>web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <context-param>
            <param-name>com.sun.faces.verifyObjects</param-name>
            <param-value>true</param-value>
        </context-param>
        <context-param>
            <param-name>com.sun.faces.validateXml</param-name>
            <param-value>true</param-value>
        </context-param>
        <context-param>
            <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
            <param-value>.xhtml</param-value>
        </context-param>
        <context-param>
            <param-name>facelets.DEVELOPMENT</param-name>
            <param-value>false</param-value>
        </context-param>
        <context-param>
            <param-name>facelets.SKIP_COMMENTS</param-name>
            <param-value>true</param-value>
        </context-param>
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.jsf</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>forward.jsp</welcome-file>
            </welcome-file-list>
        </web-app>forward.jsp:
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <jsp:forward page="template-client.jsf"/>template-client.xhtml:
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:h="http://java.sun.com/jsf/html">
        <body>
            This text above will not be displayed.
            <ui:composition template="/template.xhtml">
                This text will not be displayed.
                <ui:define name="title">
                    Facelets
                </ui:define>
                This text will also not be displayed.
                <ui:define name="body">
                    Hello from the Facelets client template!
                </ui:define>
                This text will not be displayed.
            </ui:composition>
            This text below will also not be displayed.
        </body>
    </html>template.xhtml:
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:ice="http://www.icesoft.com/icefaces/component">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title>Facelets - Template Example</title>
            <link href="#{facesContext.externalContext.requestContextPath}/css/default.css" rel="stylesheet" type="text/css" />
        </head>
        <body>
            <div id="menu">
                <ui:insert name="linemenu">
                    <ul>
                        <li><a href="../forward.jsp">Home</a></li>
                        <li><a href="about.jsf">About Us</a></li>
                        <li><a href="products.jsf">Products</a></li>
                    </ul>
                </ui:insert>
            </div>
            <div>
            <h1>
                <ui:insert name="title">Default Title</ui:insert>
            </h1>
            <p>
                <ui:insert name="body">Default Body</ui:insert>
            </p>
            </div>
        </body>
    </html>about.xhtml:
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets">
        <body>
            <ui:composition template="./../template.xhtml">
                <ui:define name="title">
                    title ABOUT
                </ui:define>
                <ui:define name="body">
                    body ABOUT
                </ui:define>
            </ui:composition>
        </body>
    </html>products.xhtml:
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets">
        <body>
            <ui:composition template="./../template.xhtml">
                <ui:define name="title">
                    title PRODUCTS
                </ui:define>
                <ui:define name="body">
                    body PRODUCTS
                </ui:define>
            </ui:composition>
        </body>
    </html>

    My folders:
    Test3
         Web Pages
              /WEB-INF
              /css
                  -default.css
              /layouts
              /portal
                  -about.xhtml
                  -products.xhtml
              -forward.jsp
              -template.xhtml
              -template-client.xhtmlPlease, I need help with this. It may is very easy to find out, I maybe skiping something
    Thank for your help anyone!!!

Maybe you are looking for