Peter,

All this info is available from the current HttpServletRequest,
accessible within your tag handler by 'pageContext.getRequest()'.

HttpServletRequest request =
(HttpServletRequest)pageContext.getRequest();

request.getServerName() ( == hostname)
request.getProtocol() ( == http/majorVersion.minorVersion)
request.getServerPort() ( == 80)
request.getContextPath() ( == /webapp/servlet)

Cheers,
Borislav

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]] On Behalf Of Peter Dolukhanov
Sent: Sunday, October 13, 2002 7:56 PM
To: [EMAIL PROTECTED]
Subject: Tag Lib/Servlet Question

Dear All,



I have successfully built a servlet that generates a GIF/JPEG file
depending on parameters that are passed to it. I am trying to expand the
functionality of it by creating a Custom Tag, that on execution with
certain parameters will return a <img> tag pointing at that specific
servlet with the correct parameters etc..



i.e. <customTag:tag1 text="abcd" width="40" position="top"> will return

<img src="http://hostname/webapp/servlet/package.servlet?text=abcd
<http://hostname/webapp/servlet/package.servlet?text=abcd&pos=top>
&pos=top" width="40">



As my tag library and servlet are in the same package, I know that my
servlet is located at
http://hostname/webapp/servlet/package.to.servlet?parameter1=value...



Is there any way for me retrieve the http://hostname/webapp portion of
the URL from the tag at runtime, as obviously I don't know from what
directory the taglib JSP is being executed from. I have tried
servletContext.getRealPath(.) but that returns me a path on the hard
disk to my web app. Any ideas how I can circumvent this problem?



Best regards,

Peter Dolukhanov

========================================================================
===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to