• Post Reply Bookmark Topic Watch Topic
  • New Topic

A reference to the request obj  RSS feed

 
EM. Lashkar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I am trying to get a reference to the requerst object so that I could get/LOG the page URL.
I tried:
1.
HttpServletRequest req ;
System.out.println("[ Debug Mode Enabled. Request in execution = " +req.getRequestURL().toString() +req.getQueryString() );
2.
System.out.println("[ Debug Mode Enabled. Request in execution = " +request.getRequestURL().toString() +request.getQueryString() );
None worked. Compile error.Cant get a handle to the request obj. Any suggestion ?
Trying to do this the a JSP page.
Thanks.
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP pages have access to several implicit variables, request being one of them.
The request implicit variable represents an instance of javax.servlet.http.HttpServletRequest, and is passed to the _jspService() method of the generated servlet at request-time.
You can use it in just the same way as you use requests in servlets. For example:
 
EM. Lashkar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark. Your suggestion helped me reEvaluate my code and found that the method signature was wrong.
request.getRequestURL()
is now request.getRequestURI()
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!