Link to home
Start Free TrialLog in
Avatar of leonidn
leonidn

asked on

Change servlet configuration when moving main class

hi all!

the class with doGet and doPost methods was here:
~/workshop_tmp/webapps/examples/WEB-INF/classes
and it was accessible from
http://xxxxxxxxxxxxx:1234/examples/servlet/HelloWorldExample

now i renamed and moved HelloWorldExample.class into misc/NewClassName.class
what changes should i make in order to make it work again?

also, i'd like to access it like this:
http://xxxxxxxxxxxxx:1234/NewClassName
what changes should i make?

tnx!
ASKER CERTIFIED SOLUTION
Avatar of mbvvsatish
mbvvsatish
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leonidn
leonidn

ASKER

> firstofall you cannot rename a class file to a NewClassName.class
> you need to change the java file name and classname and include the package name as misc
> and then recompile it.

yeah... that's what i meant... did it all in eclipse and it did all the work for me (renaming, recompiling...)


what about the other part of the question?

    (also, i'd like to access it like this:
    http://xxxxxxxxxxxxx:1234/NewClassName
    what changes should i make?)

tnx ;)
that is what my second part say's

then you need to change the servlet-class and url-pattern of your web.xml to point to the package
 and then recreate the war file and re-deploy again

<servlet>
<servlet-name>NewClassName</servlet-name>
<servlet-class>misc.NewClassName</servlet-class>
</servlet>

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