Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[HTTPUNIT] Read a *.jsp file

 
jean chretiendetroie
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I'am trying to fill a form which is on a jsp page. Yet it doesn't work.



Yet, i have an error :
java.net.UnknownHostException: jss
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)


IS it possible to fill a form on a jsp page with junit?
If the answer is yes , why is my code wrong.

thanks
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like your URL is wrong in the constructor to GetMethodWebRequest.

The String passed should be the URL that has the form you wish to fill in, i.e., something like:



The HTTPUnit cookbook should help.


-Tim
 
jean chretiendetroie
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but , if i use a URL that does not end with .jsp . For instance, .com , it works ?
What i dont know is if it is possible to read a jsp page with the methode
WebRequest req1 = new GetMethodWebRequest( URL to a jsp page);
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The URL you give will just be sent out with a HTTP GET command - like in a browser. That is, you can obtain with HTTPUnit any page you can with your browser.

There's no reason why you couldn't get a page with a '.jsp' extension - give it a go! Of course, you'll get the JSP output, not the text of the JSP itself. But this is probably what you want anyway.

As an aside, it sounds like you would benefit from doing some background reading on HTTPUnit.


-Tim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic