aspose file tools*
The moose likes Testing and the fly likes How to read JavaScript function from a Jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to read JavaScript function from a Jsp" Watch "How to read JavaScript function from a Jsp" New topic
Author

How to read JavaScript function from a Jsp

Shrikant Kulkarni
Ranch Hand

Joined: May 10, 2005
Posts: 42
Hi All,
I am facing a problem while testing a JSP page which contains some Javascript code.
When we submit a login jsp page after giving valid userId and password, the control shifts to inbox_open page. When this login page reads a javascript code, i get an error like:

com.meterware.httpunit.ScriptException: Script 'openFrameworkWindow('/digite/Request?Key=framework_main&ContainedURL=inbox_open');' failed: org.mozilla.javascript.EcmaError: TypeError: Cannot set property "location" of undefined to "/digite/Request?Key=framework_main&ContainedURL=inbox_open" (httpunit#260)

What could be the problem?
I have already placed js.jar in the classpath. What more is required?

Pls help me.

Shrikant
Ken Loh
Ranch Hand

Joined: Feb 16, 2005
Posts: 190
Could we have a look at your test codes ?
Shrikant Kulkarni
Ranch Hand

Joined: May 10, 2005
Posts: 42
Yah here is my test code:
============================================================================

public void testGoodLogin() throws Exception {
WebConversation conversation=null;
WebResponse response=null;
WebRequest request =null;
String url = "http://localhost:8080/digite/Request?Key=login";
try{
conversation = new WebConversation();
request = new GetMethodWebRequest( url );
response = conversation.getResponse(request);
response = conversation.getCurrentPage();
WebForm form = response.getFormWithName("loginForm");
form.setParameter("loginId","admin");
form.setParameter("password","111111");
response = form.submit();
}
catch(Exception e) {
e.printStackTrace();
fail("Failure::::"+ e);
}
}
============================================================================

Pls any help

Shrikant
Ken Loh
Ranch Hand

Joined: Feb 16, 2005
Posts: 190
Originally posted by shrikant ks:
Yah here is my test code:

Pls any help

Shrikant
Ken Loh
Ranch Hand

Joined: Feb 16, 2005
Posts: 190
Now, could you post us your jsp codes ? Appreciate it if you could wrap them in the code tags.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to read JavaScript function from a Jsp
 
Similar Threads
http 405 error when invoking a servlet from jsp
HELP! Weird Include problem!
How to use HttpUnit and JsUnit
Problems using custom tag with javascript
Problem using JSTL c:redirect.