Forums Register Login

servlets + including files

+Pie Number of slices to send: Send
Hi all,
I have a session validaion function that I would like to include in each servlet. I know the syntax to do this in jsp but how do I do it in a servlet. Also should the file just be a simple text file or a jsp file?
thank you david allen
+Pie Number of slices to send: Send
david-
I do not understand your question. If you say you have the validation in your jsp, then it'll be almost the same in your servlet (assuming it's a java-validation).
Also should the file just be a simple text file or a jsp file?
what file?
+Pie Number of slices to send: Send
OK my question is.
What is the syntax that allows one to include a file into a servlet. Just say I have some code that is required by each servlet and I want to embed the code at the beginning of the servlet.
How do I do that?
Regards david
+Pie Number of slices to send: Send
Hi David
You may use RequestDispatcher's include(req, res) method. But it is still not clear what code you want to include.
------------
Sainudheen
+Pie Number of slices to send: Send
Ok here it is.
In a JSP page you can can use the include directive to include the contents of a file in the jsp page. The file that you want to include may contain a function of some kind.
This is all I want to do but do it in a server. I have several servlets that all require a function in them. I want to write that function in a single file then include the file in all of the servlets thus including the function. The function will validate a session that is all.
Thanks david
+Pie Number of slices to send: Send
I finally got you (I think so).
the solution is what Sainudheen suggested. the include will execute the "included" file and it will return to the page from where it was called.
HTH
Where does a nanny get ground to air missles? Protect this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 950 times.
Similar Threads
Combine two struts applications.
drawing graphs
How to config jsp in web.xml?
Need servlet and jsp tutorial in .zip format
xml mapping Head First Servlets and JSP
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:16:17.