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!
Java EEJava

Avatar of undefined
Last Comment
mbvvsatish

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
mbvvsatish

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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 ;)
mbvvsatish

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>
Your help has saved me hundreds of hours of internet surfing.
fblack61