Solved

how to address servlets?

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
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 …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now