Solved

how to address servlets?

Posted on 2004-08-24
4
171 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 125 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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tomcat 7.0.47 download dont work 3 120
OWA issues after updates 6 101
Quickbooks 2015 - Auto Close Application after a specific period of time 3 125
PHP Curl Setup Option 4 111
Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 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