[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to address servlets?

Posted on 2004-08-24
4
Medium Priority
?
177 Views
Last Modified: 2010-03-17
I installed tomcat 5.0.27.

and make a immedate child folder "sqi" under webapp.

in the sqi folder, there are

login.html
WEB-INF - classes - LoginServlet.class
        - web.xml
the server.xml file is as the same when installed.
and the web.xml file looks like;

================
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
  <display-name>Java Test Example</display-name>
  <description>
     Java Test Example
  </description>
</web-app>
================

when I type "http://localhost/sqi/login.html" in the address bar, it works ok.

I don't know how to code in action attribute value in the login.html page.
/servlet/LoginServlet, LoginServlet, none of them works.

how can I address the servlet?

do you know some useful info how to configure web.xml and servlet.xml files?

Thanks.
0
Comment
Question by:iamjhkang
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:yuvalg
ID: 11890725
You need to add a servlet-mapping part that maps your Servlet to a url pattern you would wish to use (thats in web.xml)

Otherwise, i think the default is /servlet/<your_servlet >

for example:

 If  You already have this set:
  <servlet>
    <servlet-name>CactusServletTestRunner</servlet-name>
    <servlet-class>com.blz.gambit.framework.web.cactus.ServletTestRunner</servlet-class>
  </servlet>

You need to add this clause:

  <servlet-mapping>
    <servlet-name>CactusServletTestRunner</servlet-name>
    <url-pattern>/CactusServletTestRunner</url-pattern>
  </servlet-mapping>

Yuval.
0
 
LVL 1

Author Comment

by:iamjhkang
ID: 11898623
Yes. It works.
then do I have to add all servlets to web.xml?
isn't there a way, for example, /servlet/* other than adding every servlet to web.xml?

Thanks.
0
 
LVL 3

Accepted Solution

by:
yuvalg earned 500 total points
ID: 11900049
Glad to see its working.

Anyways, you HAVE TO have every servlet in web.xml, the only optional part is using the servlet-mapping.

Using servlet-mapping is the natural way to do what you want.
But, if you insist on using a new default you can do some URL rewriting with an apache web-server infront of your server. The server infront will receive a call for a url like http://sitename/thisServlet and will route it to http://sitename/servlet/thisServlet.

like i said before, i think the servlet-mapping is a valid option.

I hope this helps.

Yuval.
0
 
LVL 1

Author Comment

by:iamjhkang
ID: 11909479
Thanks.
do you have any articles on the configuration of web.xml or server.xml?
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question