This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
2]. also i want to know about 404 error page redirecting.. How do i do it. at my website.
For web application wide 404 page handling via a custom error page, place something similar to the following in your Deployment Descriptor (i.e. your web.xml file).
Take a look at the sample chapter 5 "Controlling Web Application Behavior with web.xml" from the book More Servlets and JavaServer Pages for more information. You can download it from the book's website www.moreservlets.com. It is a great resource on understanding the deployment descriptor file (i.e. web.xml). Of course, the book is an even better resource for understanding Servlets & JSPs as a whole You may also want to look at using a MVC framework such as Struts, but there is a bit of a learning curve in doing so.
Adopting the use of Struts, or any other framework, cannot achieve this. As Ben pointed out, it must be set up by the hosting company (or whoever has control of the server setup). It cannot be done from within the web application.
Redirecting 404 errors can be achieved via web.xml entries to define error handling.
Good point Ben & Bear. I'm so use to having direct control over both my Solaris box and my App Server that I failed to think about the possibility the hosting company may not give access to the user to configure the app/web server.
Joined: Mar 15, 2005
Thankyou Mark, Ben, Bear for your replies.. I have intimated my host to make necessary changes..
But I haven't been able to make those changes on my desktop..I use Tomcat 4.1 and I made a search for web.xml I came up with more than 15 results for it.. one each under conf, webapps\examples\WEB-INF, webapps\ROOT\WEB-INF and many more..
which file should i modify for adding the following lines for 404 error pae redirecting.. <error-page> <error-code>404</error-code> <location>/examples/jsp/error404.jsp</location> </error-page>
[I have added the above lines in web.xml file under conf file.. i have restarted ther server but nothing seems to happen when i provide invalid URL]
The web.xml file, formally known as the deployment descriptor, is something you would write for your web application, assuming you are using the recommend Java Web Application structure and deployment. Web Application are the recommended and preferred method of organizing and deploying a website.
One of the primary advantages of a Web Application is that it is (typically) completely self contained. Within a single zip like file, a .war file (WAR = Web Archive) is not only your entire Website's HTML, images, JSP's and Servlets, but any Java Libraries, and the deployment descriptor. This results in the ability to deploy and configure a website via a single file. Typically there is nothing additional to configure in the Web Server (or App Server). Before Web Applications, you typically need to either manually configure the classpath, servlet paths, and other things in the Web Server, or write scripts to do such in a consistent manner if deploying across multiple servers. The deployment descriptor, or web.xml file, now contains all this information. As such, it is an extremely important file, but also one that can have a bit of a learning curve to it.
The web.xml files you found in your search are ones from examples included with TomCat and for the TomCat server itself. As Ben mentions, for TomCat, the default app is in the directory ROOT.
You can read the ONJava.com article Java Web Applications for a very brief and high-level overview of what a web application is. Then you can look at the article Deploying Web Applications to Tomcat. These articles will give you a basic understanding of Web Applications. You can also look at the Sun Tutorial on Web Applications. The Sun tutorial does a good job of explaining web applications. You can then also tale a look at the sample chapter I referenced above as an excellent web.xml specific resource.reference.
One last thing to keep in mind that can be confusing when first using Servlets, JSPs and Web Applications; you need to determine what version of the Servlet/JSP specification your web hosting company supports. THe most current version is the Servlet 2.4/JSP 2.0 specification, but some hosting companies still only support the Servlet 2.3/JSP 1.2 Specification. There are some major differences between the two. I would recommend using on your desktop the version of TomCat that matches the same specification that your web hosting company uses. Tomcat v5.x is Servlet-2.4/JSP-2.0 compliant, Tomcat v4.x is Servlet2.3/JSP-1.2 compliant, and Tomcat v3.x is Servlet-2.2/JSP-1.1 compliant.
This all may be more information then you wanted or need at this time, but I think it is best that you at least get a basic awareness, and perhaps understanding of Web Applications as you move forward. Even simple websites can benefit for them. Nonetheless, if are only deploying a very basic site, you may be able to move forward without them. A lot of that, however, is going to depend on what your hosting company supports and allows. Since I work with and deploy web applications on dedicated servers under my control at my employer, I cannot speak well to the issues you may face with a hosting company.
I hope that helps... [ March 15, 2005: Message edited by: Mark Vedder ]
Joined: Mar 15, 2005
I understand there is a learning curve for me in this regard. I have got Core Servlets and JavaServer Pages book and iam on it..
Thanx a lot.
Joined: Mar 15, 2005
Originally posted by ramakrishna madati: Hello all,
firstly very good place for me to land in.
Iam working on a website. My host has given me details of where to put my jsp files. Its something like myservlets/jsp under my domain..