Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Login to Java site with WWW::Scripter charset issue

by mikedeklerk (Initiate)
on Oct 03, 2012 at 01:44 UTC ( [id://996955]=perlquestion: print w/replies, xml ) Need Help??

mikedeklerk has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to login to a java website using WWW::Scripter module. Using the WWW::Mechanize module works fine, but once authenticated the site has JavaScript functions that I need to call - hence needing Scripter.
After doing a large amount of troubleshooting I have found that the difference in packets sent from the click() event are the Content-Type varaibale.
Mechanize has: Content-Type: application/x-www-form-urlencoded\r\n
but Scripter has: Content-Type: application/x-www-form-urlencoded; charset="ISO-8859-1"\r\n
(This is viewed using WireShark)
This explains the error I am receiving from the website which is:

> error message: "ISO-8859-1" error stack trace: > java.nio.charset.IllegalCharsetNameException: "ISO-8859-1" > at java.nio.charset.Charset.checkName(Charset.java:305) > at java.nio.charset.Charset.lookup(Charset.java:439) > at java.nio.charset.Charset.forName(Charset.java(Inlined Com +piled Code)) > > at java.lang.StringCoding$DecoderCache.makeDecoder(StringCod +ing.java(Com > piled Code)) > at java.lang.StringCoding$1.run(StringCoding.java(Compiled C +ode)) > at java.security.AccessController.doPrivileged1(Native Metho +d) > at java.security.AccessController.doPrivileged(AccessControl +ler.java(Com > piled Code)) > at java.lang.StringCoding$DecoderCache.getDecoder(StringCodi +ng.java(Comp > iled Code)) > at java.lang.StringCoding.getDecoder(StringCoding.java(Inlin +ed Compiled Code)) > at java.lang.StringCoding.decode(StringCoding.java(Compiled +Code)) > at java.lang.String.<init>(String.java(Compiled Code)) > at java.lang.String.<init>(String.java(Inlined Compiled Code +)) > at com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostDat +a(RequestUti > ls.java(Compiled Code)) > at com.ibm.ws.webcontainer.srt.SRTServletRequest.parseParame +ters(SRTServ > letRequest.java(Compiled Code)) > at com.ibm.ws.webcontainer.srt.SRTServletRequest.getParamete +rNames(SRTSe > rvletRequest.java(Compiled Code)) > at javax.servlet.ServletRequestWrapper.getParameterNames(Ser +vletRequestW > rapper.java(Compiled Code)) > at org.apache.struts.util.RequestUtils.populate(RequestUtils +.java(Compil > ed Code)) > at org.apache.struts.action.RequestProcessor.processPopulate +(RequestProc > essor.java(Compiled Code)) > at org.apache.struts.action.RequestProcessor.process(Request +Processor.ja > va(Compiled Code)) > at org.apache.struts.action.ActionServlet.process(ActionServ +let.java(Inl > ined Compiled Code)) > at org.apache.struts.action.ActionServlet.doPost(ActionServl +et.java(Comp > iled Code)) > at javax.servlet.http.HttpServlet.service(HttpServlet.java(C +ompiled Code > )) > at javax.servlet.http.HttpServlet.service(HttpServlet.java(C +ompiled Code > )) > at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doS +ervice(Stric > tServletInstance.java(Compiled Code)) > at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._s +ervice(Stric > tLifecycleServlet.java(Compiled Code)) > at com.ibm.ws.webcontainer.servlet.IdleServletState.service( +StrictLifecy > cleServlet.java(Compiled Code)) > at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.se +rvice(Strict > LifecycleServlet.java(Inlined Compiled Code)) > at com.ibm.ws.webcontainer.servlet.ServletInstance.service(S +ervletInstan > ce.java(Compiled Code)) > at com.ibm.ws.webcontainer.servlet.ValidServletReferenceStat +e.dispatch(V > alidServletReferenceState.java(Compiled Code)) > at com.ibm.ws.webcontainer.servlet.ServletInstanceReference. +dispatch(Ser > vletInstanceReference.java(Inlined Compiled Code)) > at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter +(WebAppFilte > rChain.java(Compiled Code)) > at com.infostream.web.filters.HibernateSessionFilter.doFilte +r(HibernateS > essionFilter.java(Compiled Code)) > at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFi +lter(FilterI > nstanceWrapper.java(Compiled Code)) > at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter +(WebAppFilte > rChain.java(Compiled Code)) > at com.infostream.web.filters.IdentificationFilter.doFilter( +Identificati > onFilter.java(Compiled Code)) > at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFi +lter(FilterI > nstanceWrapper.java(Compiled Code)) > at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter +(WebAppFilte > rChain.java(Compiled Code)) > at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.ha +ndleWebAppDi > spatch(WebAppRequestDispatcher.java(Compiled Code)) > at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.di +spatch(WebAp > pRequestDispatcher.java(Compiled Code)) > at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.fo +rward(WebApp > RequestDispatcher.java(Compiled Code)) > at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAp +pInvoker.jav > a(Compiled Code)) > at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocatio +nHook(WebApp > Invoker.java(Compiled Code)) > at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation +.handleInvoc > ation(CachedInvocation.java(Compiled Code)) > at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocat +ionContext.i > nvoke(CacheableInvocationContext.java(Compiled Code)) > at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispa +tchByURI(Ser > vletRequestProcessor.java(Compiled Code)) > at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher +.service(OSE > Listener.java(Compiled Code)) > at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest +(HttpConnect > ion.java(Compiled Code)) > at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpC +onnection.ja > va(Compiled Code)) > at com.ibm.ws.http.HttpConnection.run(HttpConnection.java(Co +mpiled Code) > ) > at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Com +piled Code))
The code I'm using to test the login is:
#!/usr/bin/perl -w use WWW::Scripter; my $urlLogin = "XXX"; my $viper = WWW::Scripter->new(); $viper->use_plugin('JavaScript'); $viper->get($urlLogin); $viper->form_name('loginForm'); $viper->field(username => "xxx"); $viper->field(password => "xxx"); $viper->click();
As mentioned before this works fine if I use WWW::Mechanize instead of WWW::Scripter. Can anyone suggest what I can do to remove the charset field in the Content-Type of the packet being POST'ed.

Replies are listed 'Best First'.
Re: Login to Java site with WWW::Scripter charset issue
by Anonymous Monk on Oct 03, 2012 at 02:43 UTC

      Whoops, unfinished though there :)

      my($type, $charset) = $h->content_type_charset; $h->content_type( $type ); # ditch charset

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://996955]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-19 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found