I have website running javaserver pages that requires authentication via a login form on the front page.

If I access the page via a web browser I can submit my info and enter the site without a problem. However, when using WWW::Mechanize with the same exact login credentials I am denied entrance.

Here is the basic site setup:
login.jsp -> search.jsp -> mainIndex.jsp

When a user logs in the request is sent from login.jsp to search.jsp where the information is examined. If successful the request is redirected to the main page and the user is logged in, otherwise the request is redirected back to login.jsp with an error message asking to login to access the main page.

Here is a section of the code I am running:
my $mech = WWW::Mechanize->new(); $mech->cookie_jar(HTTP::Cookies->new()); $mech->get($target); $mech->form_name('LoginForm'); $mech->field('loginId' => $login_id); $mech->field('password' => $password); $mech->click();
For whatever reason the search.jsp page does not like the request coming from WWW::Mechanize and I cannot figure out the problem, hence the reason for the post.

I realize this info is vague but I at least needed to create a starting point. Any help is greatly appreciated!

In reply to WWW::Mechanize redirection problem by eisdrache

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.