Re: servlet quest

Michael Weller <[email protected]> Thu, 21 Oct 2004 13:41:32 +0200
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
Deepak A L wrote:
> hi i have a servlet below
> how do i call it from my jsp page
>

All you have is some "utility method" you put in a servlet. But that
doesn't matter...
just import the class's package in your jsp:
<%@ page import="test.path.*;sth.else.*;" %>
and use it like:
<%new MyServlet().getUrl(request) %>

but i doubt that's what you want.

you'd rather want a static method declared in a non-servlet class
(because your class has no servlet-features) which takes (String reqUrl,
String queryStr).

HTH!

-mw

>
> import java.util.*;
> import java.lang.*;
> import javax.servlet.*;
> import java.servlet.http.*;
> import java.io.*;
>
> public class MyServlet extends HttpServlet{
>
>  public String getUrl(HttpServletRequest req){
>   String reqUrl= req.getRequestURL().toString();
>   String queryString = req.QueryString();
>   if(queryString != null){
>     reqUrl += "?" + queryString;
>   }
>   return reqUrl;
>  }
> }
>
> ___________________________________________________________________________
> To unsubscribe, send email to [email protected] and include in the
> body of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html