You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by teh j <to...@yahoo.com.au> on 2001/06/12 05:56:40 UTC

the name of the page you are at

Hello!

I was just wondering if it is possible for a JSP to
get its own name?

ie, say we are at test.jsp, is there some variable in
the request object that lets it know that it is
test.jsp?

thanks!
Jason

_____________________________________________________________________________
http://messenger.yahoo.com.au - Yahoo! Messenger
- Voice chat, mail alerts, stock quotes and favourite news and lots more!

Re: the name of the page you are at

Posted by Luba Powell <lu...@bellatlantic.net>.
Did somebody ask for JDBC/ODBC JSP sample?
I sent it earlier, but the mail bounced back  because
.jsp type attachments not allowed!!!!!
:)

<html>
<title>Select SQL JSP</title>
<body>
<center>

<%@ page language="java" import="java.sql.*" %>

<%
 Connection con = null;
 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

 try
 {
  con = DriverManager.getConnection("jdbc:odbc:app1","","");
 }
 catch(Exception x)
 {
  out.println(x.toString());
  return;
 }

 out.println("con=" + con.toString() + "<br><br>");

 Statement st = con.createStatement();
 ResultSet rs = st.executeQuery("select one, two from Table1");
%>

<table border=1>
 <%
  while (rs.next())
  {
   out.println("<tr>\n<td>" + rs.getObject("one") + "</td>");
   out.println("<td>" + rs.getObject("two") + "</td></tr>");
   }
 %>

</table>

<%
 try
 {
  out.println("<br><br>Closing result set...");
  rs.close();
  st.close();
 }
 catch(Exception x)
 {
  out.println(x.toString());
 }
 finally
 {
  try
  {
   out.println("<br>Closing connection...");
   con.close();
  }
  catch(Exception x){}
 }
%>

</body>
</html>
----- Original Message -----
From: "Eduard Witteveen" <Ed...@omroep.nl>
To: <to...@jakarta.apache.org>
Sent: Tuesday, June 12, 2001 11:53 AM
Subject: Re: the name of the page you are at


> Dmitri Colebatch <di...@nuix.com.au> wrote:
> > On Tue, 12 Jun 2001 13:56, you wrote:
> > > I was just wondering if it is possible for a JSP to
> > > get its own name?
> > I think <%= request.getRequestURI() %> will do this for you - its part
of the
> > HttpServletRequest object, which if my memory serves me correct is
available
> > as the request variable in a JSP - note this returns the full path.
> I tried that without a good result, it wend all wrong on the contextes.
> Maybe somebody can give a good example of how i can get the AbsoluteFile
from the jsp page, since i've had this problem also a little bit :)
> I now a variable that specifies what the document root is, and attach the
relative path to it... i think it's dirty.. and it also doesnt work proper
for contexes.
> When you do it this way, depending on your operations, be sure that the
resulting file in a subdirectory of your configured document root
>
> p.s. My others are
> * How do i get the output result of a jsp page in a servlet (for caching,
and sending email in jsp)
> * How do i let my front proxy cache the jsp documents?
>
> --
> Eduard Witteveen Systeem Ontwikkelaar
> NOS Internet,  Mediacentrum Kamer 203
> +31(0)356773059 http://www.omroep.nl/
>
> Sed quis custodiet ipsos custodes? : The sixth Satire from Juvenal


Re: the name of the page you are at

Posted by Eduard Witteveen <Ed...@omroep.nl>.
Dmitri Colebatch <di...@nuix.com.au> wrote:
> On Tue, 12 Jun 2001 13:56, you wrote:
> > I was just wondering if it is possible for a JSP to
> > get its own name?
> I think <%= request.getRequestURI() %> will do this for you - its part of the 
> HttpServletRequest object, which if my memory serves me correct is available 
> as the request variable in a JSP - note this returns the full path.
I tried that without a good result, it wend all wrong on the contextes. 
Maybe somebody can give a good example of how i can get the AbsoluteFile from the jsp page, since i've had this problem also a little bit :)
I now a variable that specifies what the document root is, and attach the relative path to it... i think it's dirty.. and it also doesnt work proper for contexes.
When you do it this way, depending on your operations, be sure that the resulting file in a subdirectory of your configured document root

p.s. 	My others are
	* How do i get the output result of a jsp page in a servlet (for caching, and sending email in jsp)
	* How do i let my front proxy cache the jsp documents?

-- 
Eduard Witteveen Systeem Ontwikkelaar
NOS Internet,  Mediacentrum Kamer 203
+31(0)356773059 http://www.omroep.nl/

Sed quis custodiet ipsos custodes? : The sixth Satire from Juvenal

Re: the name of the page you are at

Posted by Dmitri Colebatch <di...@nuix.com.au>.
On Tue, 12 Jun 2001 13:56, you wrote:
> I was just wondering if it is possible for a JSP to
> get its own name?
I think <%= request.getRequestURI() %> will do this for you - its part of the 
HttpServletRequest object, which if my memory serves me correct is available 
as the request variable in a JSP - note this returns the full path.

hope this helps.

cheers
dim

>
> ie, say we are at test.jsp, is there some variable in
> the request object that lets it know that it is
> test.jsp?
>
> thanks!
> Jason
>
> ___________________________________________________________________________
>__ http://messenger.yahoo.com.au - Yahoo! Messenger
> - Voice chat, mail alerts, stock quotes and favourite news and lots more!