Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8219703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:16:09+00:00 2026-06-07T13:16:09+00:00

I am testing my webapp using grinder. I generated script using tcp proxy. It

  • 0

I am testing my webapp using grinder. I generated script using tcp proxy.
It worked fine, but when I add logger to it, following error is produced:

Error running worker process
    net.grinder.scriptengine.jython.JaythonScriptExceutionException: 
    SyntaxError ('invalid syntax', ('c:\\........ \\script_name.py', 79, 9,
     "\tlog('Arvind Purohit')"))
    (no code object) at line 0

This is my script:

# The Grinder 3.9.1
# HTTP script recorded by TCPProxy at 9 Jul, 2012 3:08:10 PM

from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from net.grinder.plugin.http import HTTPPluginControl, HTTPRequest
from HTTPClient import NVPair
log = grinder.logger.info
connectionDefaults = HTTPPluginControl.getConnectionDefaults()
httpUtilities = HTTPPluginControl.getHTTPUtilities()

# To use a proxy server, uncomment the next line and set the host and port.
# connectionDefaults.setProxyServer("localhost", 8001)

# These definitions at the top level of the file are evaluated once,
# when the worker process is started.

connectionDefaults.defaultHeaders = \
  [ NVPair('Accept-Encoding', 'gzip, deflate'),
    NVPair('User-Agent', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)'), ]

headers0= \
  [ NVPair('Accept', '*/*'),
    NVPair('Referer', 'http://192.168.1.53:8081/JSP-LOGIN/login.jsp'),
    NVPair('Accept-Language', 'en-IN'), ]

headers1= \
  [ NVPair('Accept', 'image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*'),
    NVPair('Referer', 'http://192.168.1.53:8081/JSP-LOGIN/login.jsp'),
    NVPair('Accept-Language', 'en-IN'), ]

headers2= \
  [ NVPair('Accept', 'image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*'),
    NVPair('Referer', 'http://192.168.1.53:8081/JSP-LOGIN/welcome.jsp'),
    NVPair('Accept-Language', 'en-IN'), ]

url0 = 'http://192.168.1.53:8081'

# Create an HTTPRequest for each request, then replace the
# reference to the HTTPRequest with an instrumented version.
# You can access the unadorned instance using request101.__target__.
# ========= START -================
request101 = HTTPRequest(url=url0)
request101 = Test(101, 'GET login.jsp').wrap(request101)

request102 = HTTPRequest(url=url0, headers=headers0)
request102 = Test(102, 'GET valid.js').wrap(request102)

request103 = HTTPRequest(url=url0)
request103 = Test(103, 'GET favicon.ico').wrap(request103)

# ====== login=============
request201 = HTTPRequest(url=url0, headers=headers1)
request201 = Test(201, 'POST loginmid.jsp').wrap(request201)

request202 = HTTPRequest(url=url0, headers=headers1)
request202 = Test(202, 'GET welcome.jsp').wrap(request202)

# ==========LOGOUT============
request301 = HTTPRequest(url=url0, headers=headers2)
request301 = Test(301, 'GET logout.jsp').wrap(request301)

request302 = HTTPRequest(url=url0, headers=headers2)
request302 = Test(302, 'GET login.jsp').wrap(request302)

request303 = HTTPRequest(url=url0, headers=headers0)
request303 = Test(303, 'GET valid.js').wrap(request303)


class TestRunner:
  """A TestRunner instance is created for each worker thread."""

  # A method for each recorded page.
  def page1(self):
    """GET login.jsp (requests 101-103)."""
    result = request101.GET('/JSP-LOGIN/login.jsp', None,
      ( NVPair('Accept', 'image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*'),
        NVPair('Accept-Language', 'en-IN'), ))
    log('ARVIND PUROHIT')
    grinder.sleep(13)
    request102.GET('/JSP-LOGIN/valid.js')

    grinder.sleep(62)
    request103.GET('/favicon.ico', None,
      ( NVPair('Accept', '*/*'), ))

    return result

  def page2(self):
    """POST loginmid.jsp (requests 201-202)."""

    # Expecting 302 'Moved Temporarily'
    result = request201.POST('/JSP-LOGIN/loginmid.jsp',
      ( NVPair('userName', 'A'),
        NVPair('password', 'A'),
        NVPair('Submit', 'Login'), ),
      ( NVPair('Content-Type', 'application/x-www-form-urlencoded'), ))

    grinder.sleep(15)
    request202.GET('/JSP-LOGIN/welcome.jsp')
    self.token_flag = \
      httpUtilities.valueFromBodyURI('flag') # 'edit'

    return result

  def page3(self):
    """GET logout.jsp (requests 301-303)."""

    # Expecting 302 'Moved Temporarily'
    result = request301.GET('/JSP-LOGIN/logout.jsp')

    request302.GET('/JSP-LOGIN/login.jsp')

    request303.GET('/JSP-LOGIN/valid.js', None,
      ( NVPair('If-Modified-Since', 'Tue, 03 Jul 2012 10:18:40 GMT'),
        NVPair('If-None-Match', 'W/\"4436-1341310720000\"'), ))

    return result

  def __call__(self):
    """Called for every run performed by the worker thread."""
    self.page1()      # GET login.jsp (requests 101-103)

    grinder.sleep(12893)
    self.page2()      # POST loginmid.jsp (requests 201-202)

    grinder.sleep(16403)
    self.page3()      # GET logout.jsp (requests 301-303)

def instrumentMethod(test, method_name, c=TestRunner):
  """Instrument a method with the given Test."""
  unadorned = getattr(c, method_name)
  import new
  method = new.instancemethod(test.wrap(unadorned), None, c)
  setattr(c, method_name, method)

# Replace each method with an instrumented version.
# You can call the unadorned method using self.page1.__target__().
instrumentMethod(Test(100, 'Page 1'), 'page1')
instrumentMethod(Test(200, 'Page 2'), 'page2')
instrumentMethod(Test(300, 'Page 3'), 'page3')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:16:12+00:00Added an answer on June 7, 2026 at 1:16 pm

    I’m just learning Python (less than a week), but I think it may be an issue with the \t.

    Python is reading this:

    \tlog('Arvind Purohit')
    

    But, instead of a tab, it’s expecting 4 spaces, like this:

        log('Arvind Purohit')
    

    That’s why it must be working when you copy/paste it. Make sure you’re using an editor that shows all characters to avoid this and indentation with vertical lines so you can also avoid “(no code object) at line 0” errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Python in a webapp (CGI for testing, FastCGI for production) that needs
I am testing an extjs web app by using robotframework and selenium2library, but I
I'm running my webApp using Jetty with my instrumented classes. After the shutdown of
I am using embedded Jetty to launch a webapp and I use JSP pages
I am developing a webapp for ipad and have come across an issue using
I'm writing an auto testing framework using Selenium. I am trying to test our
I'm writing Integration tests for a webapp using Spring AbstractJUnit tests and Hibernate for
I wanted to make my own WebApp for testing so I will know what
I'm trying to use Maven, Jetty and HtmlUnit to test a webapp written using
I'm trying to write a program to do automated testing on my webapp. To

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.