Link to home
Start Free TrialLog in
Avatar of tomcat_linux
tomcat_linux

asked on

Tomcat+apache

Hello everyone. Please help me out here. When I access a servlet "HelloWorld.class" from httpd its by default run on /servlet/HelloWorld. Please I want to make it /servlets/HelloWorld. I want to change from /servlet to /servlets and make it my configuration. is there any change in web.xml right me complete configuration
Avatar of tomcat_linux
tomcat_linux

ASKER

It is possible but not sure that weather change in web.xml  or redirect it from apache.
Avatar of girionis
 Yuo have to use the <url-pattern> tag to define the URL pattern for your Servlet.
Is there any example that how to add this URl-Pattern to make /servelt to /servlets and which file i will make chages please. right me complete.
 You should add it inside your <servlet-mapping> tag. Lets say that you have defined a servlet with the name "hello" like the following:

<servlet>
  <servlet-name>Hello</servlet-name>
  <servlet-class>mypackage.hellopackage.Hello</servlet-class>
  <display-name></display-name>
  <description></description>
 </servlet>

  then you can map the "Hello" Servlet to the /servlets URL pattern by doing:

<servlet-mapping>
  <servlet-name>Hello</servlet-name>
  <url-pattern>/servlets/Hello</url-pattern>
 </servlet-mapping>

  Now all the requests to http://www.mysomething.com/servlets/Hello will go to the "Hello" Servlets. Note that I am nto entirely sure if this:   <url-pattern>/servlets/Hello</url-pattern> is th eexact syntax. If that does not work experiment a bit around, try to add a * after the pattern, play around with the forward slashes etc.
Thanks that working fine one thing please tell me that how can i connect my database as well because in my servlets i define dirsconf.conf file that contain all information of database that i put in /etc/ because that was working fine with apachejserv but how can i connect with that and my document Root is /apache/htdocs. I will thankful for you this kind of help
 How do you read this dirsconf.conf file? The only thing you have to do is to change the path to the file and the system should pick it up automatically.
I have made DocumentRoot /usr/local/apache/htdocs and in server.xml i have amde changes so my servlets are running fine but i am confued what should i do for running jsp pages please.
 If you want to run JSP pages just put the, under your web applicaiton folder. If your web application is called for example "tomcat_linux" the nput your JSp pages under the "WEB-INF/tomcat_linux" folder and then run them.
Now my jsp has start working but for running that i should frist run it on port 8080 then it will start run on port 80 otherwise if i try to start this on direct port 80 before running on port 8080 it gives the Internal Server Error.


ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece 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
tomcat_linux:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept girionis' comment as answer.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jimmack
EE Cleanup Volunteer