RE: RequestDispatcher.forward()

2001-05-18 Thread Grewal, Gary
Title: RE: RequestDispatcher.forward()





ServletContext.getRequestDispatcher(java.lang.String path) takes absolute path beginign with / though the path must be relative to the current context.

You will have to use getContext(java.lang.String uripath) to get a foreign Context and then use this to get the Request Dispatcher for other context 's

Thanks and Regards,


===
Gary Grewal



-Original Message-
From: Sebastian Schulz [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 18, 2001 9:59 AM
To: [EMAIL PROTECTED]
Subject: RequestDispatcher.forward()



hi,


has somebody a work-around to produce the
same behavior as if RequestDispatcher.forward()
would work with absolute URL's?


tanks in advance!


basti





Tomcat and JApplet

2001-05-15 Thread Grewal, Gary
Title: Tomcat and JApplet





Hi ,


I do not know if this is the right forum but ...


I have tomcat running as a stand alone web server and am trying to run a JApplet using it.


I have the HTML file under the normal directory with other HTML files. Default it looks for the Applet under the same directory as the HTML file. Is there a way by which I can have it look for under a completely different directory but one which in my class path. I tried codebase=file:// etc but it threw a security exception.

Also Is there any way by which I can set up the permissions for an Applet/JApplet to use other java files on the same local host but under another completely different directory from where it was launched which is also in the system classpath.

Do I set the permission in HTML file or in the applet init() method ?? I do have a java.policy file which grants all permissions.

Is such a thing possible for a normal servlet/jsp to use java files under a completely different directory specified under the classpath or will I have to move the files over to the web-inf/classes directory.

Any Ideas / suggestions are welcome.


Thanks and Regards,


Gary Grewal





classpath

2001-05-15 Thread Grewal, Gary
Title: classpath





Hi ,


Is it possible for a normal servlet/jsp to use java files under a completely different directory specified under the classpath or will I have to move the supporting java files over to the web-inf/classes directory.

Thanks and Regards,


Gary Grewal





RE: send response to browser and continue processing in servlet.s ervice()

2001-05-07 Thread Grewal, Gary
Title: RE: send response to browser and continue processing in servlet.s ervice()





One way you can set the refresh header which auto checks for every 5 secs or 10 etc and displays the new data. This way once the data is fully there then do not set the refresh header and just send the data in your servlet. This way part of the servlet result can be displayed and rest as and when it comes.

Thanks and Regards,


===
Gary Grewal



-Original Message-
From: William Kaufman [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 07, 2001 3:17 PM
To: '[EMAIL PROTECTED]'
Subject: RE: send response to browser and continue processing in
servlet.s ervice()



 I tried SevletResponse.getOutputStream().flush() which will 
 send all output
 to the browser. However, the browser's indicator keep on spinning.


Is that a bad thing?


That is, when you're off working on something else, is the page finished or
isn't it? 


If it is finished, you can close the output stream, and do the work in
another thread. If it isn't finished (i.e., if the work you're doing has to
return to the browser's page), then the browser _should_ seem busy, because
it's waiting on more data.


(Any other solution to this, including launching more browser windows or
refreshing the page constantly for extra data, will be solved with
HTML/HTTP, and won't be specific to Tomcat, to servlets, or even to any Java
code. You can try looking around HTML web sites, like html.about.com or
www.webdeveloper.com .)


 -- Bill K.



 -Original Message-
 From: Wai-Yip Tung [mailto:[EMAIL PROTECTED]]
 Sent: Monday, May 07, 2001 12:20 PM
 To: [EMAIL PROTECTED]
 Subject: send response to browser and continue processing in
 servlet.service()
 
 
 Is there a way to send the response to browser and then continue some
 lengthy processing in the Servlet.service() method? I'm using 
 IE and I tried
 these scenarios.
 
 I tried SevletResponse.flushBuffer() which seems to have not effect.
 I tried SevletResponse.getOutputStream().flush() which will 
 send all output
 to the browser. However, the browser's indicator keep on spinning.
 I tried SevletResponse.getOutputStream().close() also but it 
 also seems to
 have no effect.
 
 The indicator won't stop until I exit Servlet.service().
 
 Because of my design, I can't just start a thread and exit. 
 Is there anyway
 I can tell Tomcat I want to remain in Servlet.service() for a 
 while. All
 output has been send and please close the socket?
 
 Thanks for any help!
 
 Wai-yip
 
 
 
 





RE: RequestDispatcher failure

2001-05-04 Thread Grewal, Gary
Title: RE: RequestDispatcher failure





Using request the URL given can be relative and using the application it has to be absolute begining with a '/'. Check to see if this may be the cause of the error.

Thanks and Regards,


===
Gary Grewal



-Original Message-
From: Mark Mynsted [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 04, 2001 10:41 AM
To: [EMAIL PROTECTED]
Subject: RequestDispatcher failure



Has anybody seen this behavior?


If I use the following code I get no errors.


RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);



If I use the following code I get a null pointer exception because
dispatcher is null.


RequestDispatcher dispatcher = application.getRequestDispatcher(url);
dispatcher.forward(request, response);



This does not make sense to me.


request is the subclass of javax.servlet.ServletRequest for this
request. application is the javax.servlet.ServletContext. I know
that application is defined because I use it all the time for logging,
e.g. application.log(This is a log message);



Both the javax.servlet.ServletRequest and javax.servlet.ServletContext 
have a getRequestDispatcher(String) method.


Sincerely yours;


Mark Mynsted




VHA Management Information Systems Client Services
[EMAIL PROTECTED]
(972) 830 - 0592, Internal x1592





Re: RequestDispatcher failure

2001-05-04 Thread Grewal, Gary
Title: Re: RequestDispatcher failure





Using request the URL given can be relative and using the application it has to be absolute begining with a '/'. Check to see if this may be the cause of the error.

Thanks and Regards,


===
Gary Grewal



-Original Message-
From: Mark Mynsted [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 04, 2001 10:41 AM
To: [EMAIL PROTECTED]
Subject: RequestDispatcher failure



Has anybody seen this behavior?


If I use the following code I get no errors.


RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);



If I use the following code I get a null pointer exception because
dispatcher is null.


RequestDispatcher dispatcher = application.getRequestDispatcher(url);
dispatcher.forward(request, response);



This does not make sense to me.


request is the subclass of javax.servlet.ServletRequest for this
request. application is the javax.servlet.ServletContext. I know
that application is defined because I use it all the time for logging,
e.g. application.log(This is a log message);



Both the javax.servlet.ServletRequest and javax.servlet.ServletContext 
have a getRequestDispatcher(String) method.


Sincerely yours;


Mark Mynsted




VHA Management Information Systems Client Services
[EMAIL PROTECTED]
(972) 830 - 0592, Internal x1592





RE: Modifying encodeURL()

2001-04-09 Thread Grewal, Gary
Title: RE: Modifying encodeURL()





You could use a hidden form field to do this and read the the parameter .


===
Gary Grewal



-Original Message-
From: David M. Rosner [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 09, 2001 3:02 PM
To: [EMAIL PROTECTED]
Subject: Modifying encodeURL()



Hi All,


Is there a way to add a tag to a url along with the session id? For 
example, when cookies are disabled Tomcat includes the jspsessionid value 
in the URL to identify the session:


http://mydomain.com/SomeScript.jsp;jspsession=ASDF1234?form=x=y



What I need to do is add a paramter that indicates which server is handling 
the session:


http://mydomain.com/SomeScript.jsp;jspsession=ASDF1234;server1?form=x=y



Is it possible to overwrite encodeURL or configure Tomcat to do this?


thanks


-dave





RE: Re-Setting the bean in a session scope

2001-04-02 Thread Grewal, Gary
Title: RE: Re-Setting the bean in a session scope





I tried doing


jsp:useBean id=myBean class=.. scope=session /
Display properties as got from the bean...
Set some properties
Display those newly set properties


% myBean = new MyPackage.MyBean(); %
Display the properties... 


It seemed to pick the default values and did appear to reset the bean but was not adding it to the session so I had to make an explicit call to 

% session.setAttribute(myBean, myBean); %
and this seemed to do the trick try and see if this works for you...



===
Gary Grewal







RE: Setting paths relative to webapp root...

2001-03-30 Thread Grewal, Gary
Title: RE: Setting paths relative to webapp root...





put the files in their respective packages and then compile them with -d path/dir/myWebApp/WEB-INF/classes option. This will move the .class files to the respective directories under WEB-INF/classes .

On the Browser type host_etc/dir/myWebApp/Servlet/PackageName.MyServlet and it should work.


===
Gary Grewal



-Original Message-
From: Gary Bentley [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 30, 2001 11:29 AM
To: [EMAIL PROTECTED]
Subject: Setting paths relative to webapp root...



Hi folks,


Can anyone answer the following?


I am using Tomcat 3.2.1 and Apache.


I have a web application that lives in a directory:


 /dir/myWebApp/


I have placed all my classes in:


 /dir/myWebApp/WEB-INF/classes


and I can get the application to work just fine...


However I now want to move some of the classes to sub-directories so I can
split the app into
a more sensible structure...for instance instead of going to:


 /dir/myWebApp/doThis


I now want to go to:


 /dir/myWebApp/interface/doThis


instead...


I have tried a few ways of doing this, mainly using the web.xml file and
nothing seems to work...


Can anyone let me know how this is done...I would like to create a few
directories...


I want to have the same class loader for all the sub-directories, in other
words I don't want to create separate web apps for each directory since this
would be very wasteful...multiple class loaders etc...


Any help is appreciated...


G.





RE: CLASSPATH

2001-03-29 Thread Grewal, Gary
Title: RE: CLASSPATH





I think you are trying to access javax.naming.* and not javax.util.naming.* Try that and then see


===
Gary Grewal



-Original Message-
From: Batsheva Raviv [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 29, 2001 10:40 AM
To: Tomcat Usr (E-mail)
Subject: CLASSPATH



I am facing problems setting the classpath in win2k and sun4.
for some reason suddenly when I write import javax.util.naming.*;
I get error: package javax.util.naming does not exist.
Isn't it part of the tools.jar package in 1.3?
my setting are
win2k
I entered it in control panel
CLASSPATH=C:\tomcat\lib\servlet.jar;C:\tomcat\lib\ant.jar;C:\tomcat\lib\jasp
er.j
ar;C:\tomcat\lib\parser.jar;C:\tomcat\lib\webserver.jar;C:\jdk1.3.0_02\lib\t
ools
.jar;C:\tomcat\ems\ems\WEB-INF\classes
( I copied it from command set)
Unix
set classpath (usr/java/lib/tools.jar ~/jars/)
when I type set I get :
classpath (usr/java/lib/tools.jar /home/braviv/jars/)


please help,


Batsheva





RE: ClassNotFoundException

2001-03-26 Thread Grewal, Gary
Title: RE: ClassNotFoundException





What directories are your HTML and your JSP files and your Servlets. Generally JSP files are in the HTML directory or directories below it while servlets are in your web-inf/classes directory. What are you typing on the browser window

===
Gary Grewal




-Original Message-
From: Michael Garthwaite [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 26, 2001 1:24 PM
To: [EMAIL PROTECTED]
Subject: ClassNotFoundException



I've new to servlets and jsp and have just installed Tomcat so forgive
me if I'm missing something really simple here. I've searched the
archives and not found any answers. I've created a new webapp as
detailed in the instructions that I downloaded. The servlets and html
files work fine but when I try to load a jsp the browser diplays a 404
error and I get a ClassNotFoundException in the command window. I'm
running Tommcat 3.2.1 with Linux/Apache. Can anyone help me out.


Michael Garthwaite





RE: Java Question on Inheritance

2001-03-22 Thread Grewal, Gary



No. 
The way you are doing means you are calling .toURL() method on what ever is 
returned by the method getThumb(). Unless getThumb returns a type of Object of 
type SuperOne or it's sub-class you cannot call this method and you should see a 
compile time error.

What 
you can do is 

URL 
url = toURL( myImage.getThumb() ); in your SuperOne or its 
sub-class.

=== Gary 
Grewal 

  -Original Message-From: Ryan 
  [mailto:[EMAIL PROTECTED]]Sent: Thursday, March 22, 2001 10:38 
  AMTo: [EMAIL PROTECTED]Subject: Java 
  Question on Inheritance
  
  I don't really know what to call what I'm having trouble with but here is 
  what I am trying to do.
  
  I have asuperclass called SuperOne, it has a method to convert a 
  string to a URL formatcalled toURL().
  
  I havean Image class that is a subclass of SuperOne. It holds 
  astringstoringthe local path of the image 
  onmyharddrive. This subclass contains a method to get the 
  corresponding thumbnail of the image on my harddrive. The method is called 
  getThumb().
  
  
  Ina thirdclass I want to instantiate an Image object 
  something like:
   Image myImage = new Image("/home/pic.gif");
  
  
  Ultimately, I want to get the thumb of this Image and convert it to a 
  URL. I want to be able to do this efficiently and use something like the 
  following syntax.
  
   myImage.getThumb().toURL()
  
  
  Is this possible?
  
  
  thanx
  -ryan


RE: Refresh

2001-03-22 Thread Grewal, Gary
Title: RE: Refresh





In servlets you can override the getLastModified method and have it return the date-time it was last modified. Also you can set the header Refresh to what ever time you want to refresh your browser. Try with JSP and let me know if it worked.

===
Gary Grewal




-Original Message-
From: Ryan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 22, 2001 10:41 AM
To: [EMAIL PROTECTED]
Subject: Re: Refresh



What I have to do most of the time is 'touch' the jsp file manually. Then
the page gets updated.


-ryan


- Original Message -
From: Jean-Francois Pelletier [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, March 22, 2001 8:18 AM
Subject: Refresh



 Is there a configuration to check if the jsp file had been change. If it
 changed, recompile it else work with the compile file.

 The problem is when I change a jsp file, tomcat doesn't look if there is a
 change in the file.

 How can I resolve this problem 

 Jeff






RE: Question on import javax.servlet.*;???

2001-03-22 Thread Grewal, Gary
Title: RE: Question on import javax.servlet.*;???





I hope you have downloaded the servlet.jar and also your classpath points to it. 


===
Gary Grewal



-Original Message-
From: Mick Sullivan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 22, 2001 3:37 PM
To: [EMAIL PROTECTED]
Subject: Question on import javax.servlet.*;???



Hi
Does anyone know why I get the following error when I try to import
import javax.servlet.*; AND
import javax.servlet.http.*;
I need them for my loginHandler to use sendRedirect etc.
This is the error:


C:\JBuilder35\jdk1.2.2\binjavac 
c:\tomcat\webapps\projectuser\web-inf\classes\l
oginHandler.java
c:\tomcat\webapps\projectuser\web-inf\classes\loginHandler.java:7: Package 
java.
servlet not found in import.
import java.servlet.*;
 ^
c:\tomcat\webapps\projectuser\web-inf\classes\loginHandler.java:8: Package 
java.
servlet.http not found in import.
import java.servlet.http.*;


Anyone have any ideas? The answer is probably straight forward (as usual)
Thanks in advance,
Mick




_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.





RE: SSL--Session Expiry

2001-03-21 Thread Grewal, Gary



Try 
encodeRedirectURL() because rules are different for encoding for redirect to own 
web-page. Also try % response.sendRedirect(..) % directly instead of 
using jsp:forward 

=== Gary 
Grewal 

  -Original Message-From: Seshagiri Dev Kurmana 
  [mailto:[EMAIL PROTECTED]]Sent: Wednesday, March 21, 2001 
  4:30 AMTo: [EMAIL PROTECTED]Subject: 
  SSL--Session ExpiryImportance: High
  Hi all,My environment is WinNT, Tomcat3.2, 
  jsse1.0.2.Everything is working fine with cookie enabled browsers.But when I 
  disable cookies in the browsers the session id is changingand 
  consequently the original session is becoming null.
  I tried to do some jugglery with 
  response.sendRedirect(myUrl),jsp:forward page="%=myUrl%"/ 
  after encoding the url.
  But I'm unable to find a solution.
  
  Any help would be greatly 
  appreciated.thanks,
  Seshagiri
  
  
  


RE: problems with forward in a servlet

2001-03-19 Thread Grewal, Gary
Title: RE: problems with forward  in a servlet





in forwarding using RequestDispatcher, try String url = encodeRedirectURL(url); and send this url as your forward url for session tracking. May be you need to do a similiar thing on the JSP side too while trnsferring the control back.

===
Gary Grewal
Contractor NEC America
Phone: 214-262-5911
E-Mail: [EMAIL PROTECTED]



-Original Message-
From: SEEMANTINI GODBOLE [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 10:23 AM
To: '[EMAIL PROTECTED]'
Subject: problems with forward in a servlet



Hi,


I am running into a problem when using forward method in my servlet to
forward the HttpRequest to a JSP page.


The servlet looks like this


public void doGet(HttpServletRequest request, HttpServletResponse
response)
 throws IOException, ServletException
{


 HttpSession session = request.getSession(true);
 System.out.println(ID  + session.getId());


 //do bunch of business logic here
 //do more things
 .
 .
 .



getServletConfig().getServletContext().getRequestDispatcher(theJSPPage).forw
ard(request,
response);


}


everything works except the forward part. Every time a JSP is displayed
as a result of forward method, the user is supposed to fill in stuff in
the page and get back to the same servlet after he submits on the page.


However, when the servlet takes over the second time, it has to create a
new session, and the SessionID is changed.
The expected behavior was that the session would have been maintained
though the control was passed from servlet-JSp-back to servlet.


If I comment the forward code statement and replace it by some code such
as


 PrintWriter out = response.getWriter();
 out.println(htmlheadtitleAlternative
methods/title/head);
 out.println(body);


and give a href to bring back the users to the same servlet, in that
case the session is retained.


Any ideas? Anyone? Anyone?


Thanks,
Seemantini Godbole





RE: include problem

2001-03-19 Thread Grewal, Gary
Title: RE: include problem





instead of ../ just do level21/b.jsp 


===
Gary Grewal
Contractor NEC America
Phone: 214-262-5911
E-Mail: [EMAIL PROTECTED]



-Original Message-
From: Kishor K [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 3:55 AM
To: Tomcat User Mailing List
Subject: include problem



hi,


i have the following directory structure


root - level1 -level21


 -level22


 -level23


i hav a file a.jsp in the level1 directory.



how can i include the file a.jsp 
in files b.jsp in level21, c.jsp level22, d.jsp in level 23


this is what i have done


%@ include file=../a.jsp%


is something wrong in the syntax?


thanx in advance
kishor





_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com





RE: Closing ResultSet and Statement?

2001-03-19 Thread Grewal, Gary
Title: RE: Closing ResultSet and Statement?





You close the statement Object by calling .close() on it.


===
Gary Grewal



-Original Message-
From: Dianne Cree [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 4:33 PM
To: [EMAIL PROTECTED]
Subject: RE: Closing ResultSet and Statement?



sorry, rs.close is asp. the correct java code came a few mails ago


-Original Message-
From: Dianne Cree [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 2:25 PM
To: [EMAIL PROTECTED]
Subject: RE: Closing ResultSet and Statement?



rs.close, isn't it?


-Original Message-
From: Mick Sullivan [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 12:49 PM
To: [EMAIL PROTECTED]
Subject: Closing ResultSet and Statement?



Hi
Does anyone know how to close a ResultSet?
Heres my code:
public String getName() throws Exception {
   Statement statement = connection.createStatement();
   int myInt = 1;
   ResultSet rs = statement.executeQuery(SELECT Name+
FROM nameAddress +
WHERE ID = (+
   myInt + ));
  rs.next();
  String myString = rs.getString(Name);
 //change the resultSet to a string
 //so it can be used by the jsp page
   return myString;
 }
Any help at all would be much appreciated
Thanks in advance,
Mick




_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.






RE: Closing ResultSet and Statement?

2001-03-19 Thread Grewal, Gary
Title: RE: Closing ResultSet and Statement?





or you can even close the Connection object by calling .close() on it. this will close all the underlying statement and ResultSet Object. I hope this is what you meant by close.

===
Gary Grewal
Contractor NEC America
Phone: 214-262-5911
E-Mail: [EMAIL PROTECTED]



-Original Message-
From: Dianne Cree [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 4:33 PM
To: [EMAIL PROTECTED]
Subject: RE: Closing ResultSet and Statement?



sorry, rs.close is asp. the correct java code came a few mails ago


-Original Message-
From: Dianne Cree [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 2:25 PM
To: [EMAIL PROTECTED]
Subject: RE: Closing ResultSet and Statement?



rs.close, isn't it?


-Original Message-
From: Mick Sullivan [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 12:49 PM
To: [EMAIL PROTECTED]
Subject: Closing ResultSet and Statement?



Hi
Does anyone know how to close a ResultSet?
Heres my code:
public String getName() throws Exception {
   Statement statement = connection.createStatement();
   int myInt = 1;
   ResultSet rs = statement.executeQuery(SELECT Name+
FROM nameAddress +
WHERE ID = (+
   myInt + ));
  rs.next();
  String myString = rs.getString(Name);
 //change the resultSet to a string
 //so it can be used by the jsp page
   return myString;
 }
Any help at all would be much appreciated
Thanks in advance,
Mick




_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.