?
Solved

how to address servlets?

Posted on 2004-08-24
4
Medium Priority
?
176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

650 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