• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat Installation

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After doing the setting in autoexec.bat and changing the memory throu ms dos prompt I am unable to start tomcat.
When I click on startup.bat it says
You must Java_home to point at your java development kit.
Any help will be greatly appreciated.
Thanks
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming you use Win98 and have unzipped tomcat to c:\tomcat and have your jdk at c:\jdk1.3
Edit c:\tomcat\bin\startup.bat and add
set JAVA_HOME=c:\jdk1.3
at the top.. JAVA_HOME in caps, no space between E=c:\ (had problems when I used spaces and just dropped them thereafter)
Then right click the startup.bat file and -> properties -> memory
In the intial env. memory (top right) increase it to the max that's there in the dropdown box (4096?) and click on ok. This will create another shortcut in the c:\tomcat\bin directory and double clicking this should get tomcat started.
you DONT run autoexec everytime you want to start tomcat. Thats run only once when the system boots.. You could set JAVA_HOME and TOMCAT_HOME in there too.. but your previous post had some inconsistencies (c:\jakarta-tomcat in one place, c:\tomcat in another; and at one spot, your overwrite path by path = c:\.. instead of path=%path%;c:\..)
 
Seema Bhatia
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a bunch.I am very happy to install it was struggling for 2 hrs or so.
One more question.
Where to put the jsp files and java files in tomcat?
Thanks for your help.
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great ! You should be able to access the pages by http://localhost:8080 now.. This is actually the c:\tomcat\webapps\root directoy
You can make a new directory called seema in \webapps you cna place .jsp's in this seems direcoty
you also need to make a web-inf folder and a classes folder within that for your .class files
c:\tomcat\webapps\seems -> pages.jsp's accessed thru http://localhost:8080/seema/pages.jsp
and c:\tomcat\webapps\web-inf\classes -> Hello.class accessed thru http://localhost:8080/seems/servlet/Hello
 
Seema Bhatia
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well no success.
I made this directory structure under \webapps.
A directory by name "Anshu" and then a folder by name "Web-inf" and in "Web-inf" folder two folders by name "classes" and "jsp".
and inserted a hello.jsp file in jsp folder.
Tried executing by http;//localhost:8080/Anshu/jsp/hello.jsp but error saying:
Not Found (404)
Original request: /Anshu/jsp/hello.jsp
Not found request: /Anshu/jsp/hello.jsp
But when I try to insert the same page under the directory structure created by tomcat i.e. in examples\jsp directory and execute it by this url it runs. http://localhost:8080/examples/jsp/hello.jsp
What is happening unable to figure out?
Please help me your help will be once again appreciated.
Thanks a bunch
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The web-inf\jsp folder will be used by tomcat to put compiled jsp's.. you put jsp's in /Anshu just as you would any .htm files
c:\tomcat\webapps\Anshu\test.jsp accessed as http://localhost:8080/Anshu/test.jsp
[This message has been edited by Mak Bhandari (edited April 30, 2001).]
 
Seema Bhatia
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am tired but I succeded.
I appreciate your help in helping me to figure out my problems. I think I am almost set to learn jsp.
By the way I am referring to Professional JSP by wrox is it a good book or not?
Anyway it was a pleasure talking to you.
BTW in which part of USA are you in and in which company are u working?

See u whenever I need help.
Can u give me ur email address?
Thanks
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are most welcome. I'm from CT. How about u ?
I dont like wrox books since they are written by 10 - 20 authors and usually lack consistancy. JSP by Duane Fields and Core Servlets by Marty Hall have been my favorite..
 
Seema Bhatia
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am from Colorado Springs.
One more question.
I am new to servlets concept.
If I am writting this code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
}
}
My question is by which file name extension I need to save( I think so hello.class) and I am saving this file in anshu\web-inf\classes
and when I test it by the URL. http://localhost:8080/anshu/servlet/hello
It gives me error.

Error: 500
Location: /anshu/servlet/hello
Internal Servlet Error:
java.lang.NullPointerException
at java.lang.ClassLoader.resolveClass0(Native Method)
at java.lang.ClassLoader.resolveClass(ClassLoader.java:588)
at org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java:518)
at org.apache.tomcat.loader.AdaptiveServletLoader.loadClass(AdaptiveServletLoader.java:174)
at org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:265)
at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
at org.apache.tomcat.core.Handler.service(Handler.java:254)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)

Please help me once more.
Thanks
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.. you have to save this file as a .java file somewhere on your comp. Say, c:\JavaSrc\HelloWorld.java
I dont know if you are using an IDE so we'll compile from the dos prompt
Open your dos prompt and go to c:\JavaSrc Then do a javac HelloWorld.java
In case you get errors, this may help you
set PATH=c:\jdk1.3\bin
set CLASSPATH=c:\tomcat\lib\servlet.jar
These two commands will change the sys settings only for the current dos window so you dont have to worry about your environment settings for tomcat or other applications being upset.
Then do the javac HelloWorld.java and it SHOULD compile to HelloWorld.class Move / copy the HelloWorld.class file to c:\tomcat\webapps\Anshu\web-inf\classes\HelloWorld.class and access it as http://localhost:8080/Anshu/servlet/HelloWorld
The comcept of moving the HelloWorld.java to the classes directory would work if you were using a servlet server like resin that automatically compiles the .java files. Tomcat, unfortunatly, does not and you have to compile them yourself..
And i remember reading you saying that you have J2EESDK loaded.. You dont need the EE SDK for simple things like servlet compilation and tomcat running (even though JSP's/Servlets are a part of the J2EE specification)
Good luck.

[This message has been edited by Mak Bhandari (edited April 30, 2001).]
[This message has been edited by Mak Bhandari (edited April 30, 2001).]
 
Seema Bhatia
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I succeded in compiling and it makes HelloWorldExample.java file and I copied it in the right directory but when I try to access it by this URL:
It gives me error http://localhost:8080/anshu/servlet/HelloWorldExample

Error: 500
Location: /anshu/servlet/HelloWorldExample
Internal Servlet Error:
java.util.MissingResourceException: Can't find bundle for base name LocalStrings, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:707)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:604)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:559)
at HelloWorldExample.doGet(helloworldexample.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
I think so it is giving error in the java file at this line
ResourceBundle rb =
ResourceBundle.getBundle("LocalStrings",request.getLocale());

I have no idea what it is expecting as I have not written the code of this example I just copied it from tomcat\examples directory.
If you have any idea do let me know.
Thanks.
You are a great help to me.
If I do this example today it will be a big achievement for me
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still remember the feeling of my first HelloWorld servlet !
Why do you do HelloWorldExample ? Since your public class in the java code is HelloWorld, you file should be named HelloWorld.java, it should compile into HelloWorld.class and you should call /anshu/servlet/HelloWorld
Why the 'Example' ??
 
Seema Bhatia
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See I intially had my class as HelloWorldExample but I changed it to HelloWorld.java and in the code also I changed it.
The code of HelloWorld.java is as follows:
/* $Id: HelloWorldExample.java,v 1.2.4.1 2000/07/05 17:45:01 nacho Exp $
*
*/
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* The simplest possible servlet.
*
* @author James Duncan Davidson
*/
public class HelloWorld extends HttpServlet {

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
ResourceBundle rb =
ResourceBundle.getBundle("LocalStrings",request.getLocale());
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
String title = rb.getString("helloworld.title");
// out.println("<title>" + title + "</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">");
out.println("<body>");
// note that all links are created to be relative. this
// ensures that we can move the web application that this
// servlet belongs to to a different place in the url
// tree and not have any harmful side effects.
// XXX
// making these absolute till we work out the
// addition of a PathInfo issue
out.println("<a href=\"/examples/servlets/helloworld.html\">");
out.println("<img src=\"/examples/images/code.gif\" height=24 " +
"width=24 align=right border=0 alt=\"view code\"></a>");
out.println("<a href=\"/examples/servlets/index.html\">");
out.println("<img src=\"/examples/images/return.gif\" height=24 " +
"width=24 align=right border=0 alt=\"return\"></a>");
out.println("<h1>" + title + "</h1>");
out.println("</body>");
out.println("</html>");
}
}
and When I compile it it compiles fine and I copy it in the \anshu\web-inf\classes directory and try to access it by this URL:
http:\\localhost:8080\anshu\servlet\HelloWorld
It bounces an error
Error: 500
Location: /anshu/servlet/HelloWorld
Internal Servlet Error:
java.util.MissingResourceException: Can't find bundle for base name LocalStrings, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:707)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:604)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:559)
at HelloWorld.doGet(helloworld.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Same error as it was before:
There is something wrong in the code of HelloWorld.java at this line.
ResourceBundle rb =
ResourceBundle.getBundle("LocalStrings",request.getLocale());
Any idea what does this mean?
You must be having fun reading my errors as u have already executed your first servlet page.
Anyway waiting for ur reply.
Thanks
 
Seema Bhatia
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey I did it it was looking for some local properties file I copied it into c:\javasrc and compiled it again and copied it to the desired folder and tried again I succeded.
Try try again and you will succeed -Moral of the discussion
Thanks for ur great help.
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so now you know the feeling of YOUR first servlet. COngrats !
 
Seema Bhatia
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I do I will remember this day .
Anyway have a good day !!
See u tomarrow.Hoping for it that I will not ask u any more questions today.
Thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic