RE: directory structure

2009-09-13 Thread Daniel Blumenthal
 If you're referring to during the development phase

Yes, during the development phase.

 the IDEs 
 I've worked with such as NetBeans and Eclipse does it for you 
 automatically.  I don't remember if NetBeans actually make a 
 war or not but it does autodeploy.  Eclipse will auto 
 synchronize and sometimes it will auto-redeploy the app or 
 restart TC depending on what was changed.  What IDE are you 
 using? 

Hmm...  I tend to use Eclipse primarily as a Java-aware text editor
(control-click to get to a declaration is invaluable), but my build is done
using ant.

My old solution was to simply do all of my development inside the tomcat
webapps directory.  This worked all right, except that it was incredibly
ugly and caused bizarre problems from time to time (e.g., when allowing
tomcat to autoload altered classes).  I'm trying to get everything set up
right.

The only way I can see to do it is to play weird tricks with symbolic links,
but this seems like a bad solution.

Thoughts?


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: directory structure

2009-09-13 Thread David Kerber

Daniel Blumenthal wrote:

If you're referring to during the development phase



Yes, during the development phase.

  
the IDEs 
I've worked with such as NetBeans and Eclipse does it for you 
automatically.  I don't remember if NetBeans actually make a 
war or not but it does autodeploy.  Eclipse will auto 
synchronize and sometimes it will auto-redeploy the app or 
restart TC depending on what was changed.  What IDE are you 
using? 



Hmm...  I tend to use Eclipse primarily as a Java-aware text editor
(control-click to get to a declaration is invaluable), but my build is done
using ant.

My old solution was to simply do all of my development inside the tomcat
webapps directory.  This worked all right, except that it was incredibly
ugly and caused bizarre problems from time to time (e.g., when allowing
tomcat to autoload altered classes).  I'm trying to get everything set up
right.

The only way I can see to do it is to play weird tricks with symbolic links,
but this seems like a bad solution.

Thoughts?
  
Yes:  use the full power of Eclipse, and let it do your builds, 
debugging and deployments.


D



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: directory structure

2009-09-12 Thread Tommy Pham
--- On Sat, 9/12/09, Daniel Blumenthal dan...@wordchamp.com wrote:

 From: Daniel Blumenthal dan...@wordchamp.com
 Subject: directory structure
 To: users@tomcat.apache.org
 Date: Saturday, September 12, 2009, 9:42 PM
 I'm reorganizing an existing project
 according to the generally accepted
 Java directory structure
 (http://java.sun.com/blueprints/code/projectconventions.html#23136),
 and
 everything seems to be working all right, but there's one
 thing I don't
 understand that seems like it should be a common problem
 with a common
 solution.  Currently, when I build a project for
 testing, it compiles the
 Java source, bundles everything into a .war, inserts it
 into the Tomcat
 webapps directory, and expands it.  However, in order
 to make a small change
 to a jsp file, css file, etc., I have to go through the
 entire build process
 again.
  
 I'd like to be able to set up a system in which I can make
 a change to a css
 file (or whatever) and see the change after reloading the
 page - i.e.,
 without having to run another build.

If you're referring to during the development phase, the IDEs I've worked with 
such as NetBeans and Eclipse does it for you automatically.  I don't remember 
if NetBeans actually make a war or not but it does autodeploy.  Eclipse will 
auto synchronize and sometimes it will auto-redeploy the app or restart TC 
depending on what was changed.  What IDE are you using?  If you're referring to 
production, isn't a bit a dangerous/risky to be doing changes as you mention?  
Production should be touched after thorough testing of the app on development 
server, correct me if I'm wrong.

Regards,
Tommy

  
 Is there a common way to do this?


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: directory structure

2009-09-12 Thread Hassan Schroeder
On Sat, Sep 12, 2009 at 7:42 PM, Daniel Blumenthal dan...@wordchamp.com wrote:

 I'd like to be able to set up a system in which I can make a change to a css
 file (or whatever) and see the change after reloading the page - i.e.,
 without having to run another build.

Uh, wouldn't that just depend on your build system (and platform)?

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
twitter: @hassan

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Directory Structure and Can't Find Resources in Tomcat

2006-05-21 Thread Hassan Schroeder

On 5/20/06, Allen Williams [EMAIL PROTECTED] wrote:

Sorry, it didn't work.  Once again, in my browser I have:

HTTP Status 404 - /login
Description: The requested resource (/login) is not available.



form name=loginForm method=post action=/login


Looking back at your original email -- is this your ROOT context?
If not -- if it's smsinfo -- then of course the above path has to
reflect that, e.g.

form name=loginForm method=post action=/smsinfo/login

The url-mapping in web.xml is relative to the context; HTML href or
form action attributes are relative to the server.

HTH,
--
Hassan Schroeder  [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Directory Structure and Can't Find Resources in Tomcat

2006-05-21 Thread Hassan Schroeder

On 5/21/06, Allen Williams [EMAIL PROTECTED] wrote:


Do you know where I can find a GOOD reference on how Tomcat resolves that
stuff?  I've looked at most of the official docs, and a lot of stuff on
the web, but they more or less allude to it peripherally, as though it is
already understood.  This will be particularly important in the future, when
I plan to set up multiple virtual servers.


I've pretty much relied on  the servlet spec and the Tomcat docs -- it's
too easy to find other resources (i.e., books, tutorials, whatever) that are
simply out of date, and hence actually detrimental to understanding.


Also, now that I have this rudimentary piece of code working, I am off to
integrate Apache and Tomcat. I started doing this last year, spent about a
week on it and never got it quite working, but had to leave.  Any good
references there?


Do you have a burning *need* to do this (*must* run PHP, FastCGI for
Rails, or some such)? If not, I'd say don't do it :-)   And if you must, get
a second IP and run Apache httpd separately on that.

The list archives are full of discussion on this -- that may help you decide.

Regardless, good luck,
--
Hassan Schroeder  [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Directory Structure and Can't Find Resources in Tomcat

2006-05-21 Thread Allen Williams


 -Original Message-
 From: Hassan Schroeder [mailto:[EMAIL PROTECTED]
 Sent: Sunday, May 21, 2006 4:02 PM
 To: Tomcat Users List
 Subject: Re: Directory Structure and Can't Find Resources in Tomcat
snip
/snip
  Also, now that I have this rudimentary piece of code working, I
 am off to
  integrate Apache and Tomcat. I started doing this last year,
 spent about a
  week on it and never got it quite working, but had to leave.  Any good
  references there?

 Do you have a burning *need* to do this (*must* run PHP, FastCGI for
 Rails, or some such)? If not, I'd say don't do it :-)   And if
 you must, get
 a second IP and run Apache httpd separately on that.

I don't really have a burning need, but would consider it educational (is
this
a good reason?;-) and was laboring under the impression (rightly or wrongly)
that
it would increase performance because Apache was better at static content
than
Tomcat.  Would it change the argument if I was hosting multiple,
independent,
disparate virtual hosts?

Would the fact I was using a second IP make a difference in the ease of
configuration
and/or maintenance?

Again, thanks a lot!


 Regardless, good luck,
 --
 Hassan Schroeder  [EMAIL PROTECTED]

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Directory Structure and Can't Find Resources in Tomcat

2006-05-21 Thread Hassan Schroeder

On 5/21/06, Allen Williams [EMAIL PROTECTED] wrote:


I don't really have a burning need, but would consider it educational


So's putting your hand on a hot stove burner; the value of the lesson
is yours to decide :-)


... was laboring under the impression (rightly or wrongly)
that it would increase performance because Apache was better
at static content


An out-of-date assumption; again, check the archives for more recent
discussion on that. I have one very graphics-intensive site in production
and see no responsiveness issues.


 Would it change the argument if I was hosting multiple,
independent,  disparate virtual hosts?


No; fronting with Apache httpd is even more of a PITA in that case.


Would the fact I was using a second IP make a difference in the ease
of configuration and/or maintenance?


The second IP approach is only suggested if you *need* httpd for some
non-Java applications. Keeping them totally separate from your Tomcat
installation seems a lot easier (more maintainable) to me. YMMV. :-)

HTH!
--
Hassan Schroeder  [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Directory Structure and Can't Find Resources in Tomcat

2006-05-20 Thread Mladen Adamovic
I would suggest you to install and work with Netbeans 5.0. Netbeans 5.0 
have bundled Tomcat which work out of the box. Than you will not have 
problems like these before deployment.


Allen Williams wrote:

Well, I can't figure out this directory structure and finding stuff at all.
 
Here are my directory listings


docroot= /usr/share/tomcat5/webapps/smsinfo
***
anw-dev:/usr/share/tomcat5/webapps/smsinfo$ ls -laF
total 20
drwxr-xr-x  3 anw root 4096 2006-05-19 21:14 ./
drwxr-xr-x  9 tomcat5 root 4096 2006-05-13 16:10 ../
-rw-r--r--  1 anw anw   564 2006-05-19 21:20 login.jsp
drwxr-xr-x  4 anw anw  4096 2006-05-19 21:15 WEB-INF/
-rw-r--r--  1 anw anw   241 2006-05-19 21:20 welcome.jsp


anw-dev:/usr/share/tomcat5/webapps/smsinfo/WEB-INF$ ls -laF
total 20
drwxr-xr-x  4 anw anw  4096 2006-05-19 21:15 ./
drwxr-xr-x  3 anw root 4096 2006-05-19 21:14 ../
drwxr-xr-x  3 anw root 4096 2006-05-18 20:27 classes/
drwxr-xr-x  2 anw root 4096 2006-05-13 15:49 lib/
-rw-r--r--  1 anw anw   440 2006-05-19 21:18 web.xml

(lib is empty)
***
anw-dev:/usr/share/tomcat5/webapps/smsinfo/WEB-INF/classes$ ls -laF
total 12
drwxr-xr-x  3 anw root 4096 2006-05-18 20:27 ./
drwxr-xr-x  4 anw anw  4096 2006-05-19 21:15 ../
drwxr-xr-x  2 anw root 4096 2006-05-18 20:27 UserConfig/
*
anw-dev:/usr/share/tomcat5/webapps/smsinfo/WEB-INF/classes/UserConfig$
ls -laF
total 12
drwxr-xr-x  2 anw root 4096 2006-05-18 20:27 ./
drwxr-xr-x  3 anw root 4096 2006-05-18 20:27 ../
-rwxr-xr-x  1 anw root 1322 2006-05-19 21:18 login.class*
*

Here is the source to login.jsp (located in docroot,
/usr/share/tomcat5/webapps/smsinfo):

html
head
titleSMS Information Transfer Login Page/title
meta http-equiv=Content-Type content=text/html;
charset=iso-8859-1
/head

body bgcolor=#FF onload=document.loginForm.username.focus()
!-- form name=loginForm method=post
action=/servlet/UserConfig.login --
form name=loginForm method=post
action=WEB-INF/classes/UserConfig.login
pUser Name:input type=text name=username/p
pPassword:input type=password name=password/p
pinput type=Submit name=Submit/p
/form
/body
/html

*
Here is the source to login.class:

package UserConfig;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class login extends HttpServlet
{
private String target=/welcome.jsp;
private String getUser(String username, String password)
{
return username;
}
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException
{
// If it is a Get request, forward to doPost
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException
{
// Get user name and password:
String username= request.getParameter(username);
String password= request.getParameter(password);
String user= getUser(username, password);
// Add fake user to the request
request.setAttribute(USER, user);
ServletContext context= getServletContext();
RequestDispatcher dispatcher= context.getRequestDispatcher(target);
//target defined above
dispatcher.forward(request, response);
}
}
***
Here is the source for my web.xml file:

?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/j2ee/dtds/web-app_2_3.dtd;

web-app
servlet
servlet-namelogin/servlet-name
servlet-classUserConfig.login/servlet-class
/servlet
servlet-mapping
servlet-namelogin/servlet-name
url-pattern/servlet/login/url-pattern
/servlet-mapping
/web-app
***

As can be seen, all this is very simple, my very first Tomcat web app.  I
have
followed the instructions in

http://tomcat.apache.org/tomcat-5.5-doc/appdev/index.html

When I go to http://localhost:8180/smsinfo/login.jsp, I get the form, input
some text, then get the following screen from tomcat:

HTTP Status 404 - /smsinfo/WEB-INF/classes/UserConfig.login

Type: Status report

Message: /smsinfo/WEB-INF/classes/UserConfig.login

Description: The requested resource
(/smsinfo/WEB-INF/classes/UserConfig.login) is not available.
Apache Tomcat/5.0
*

I've been screwing around with this for days, reading books and the web
help,
but can't find out what's wrong.  Any help is greatly appreciated.

TIA and regards,
anw

Re: Directory Structure and Can't Find Resources in Tomcat

2006-05-20 Thread Gregg Leichtman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Try putting your webapp under:

docroot= /usr/share/tomcat5/webapps/ROOT/smsinfo

  -= Gregg =-

Mladen Adamovic wrote:
 I would suggest you to install and work with Netbeans 5.0. Netbeans
 5.0 have bundled Tomcat which work out of the box. Than you will not
 have problems like these before deployment.

 Allen Williams wrote:
 Well, I can't figure out this directory structure and finding stuff
 at all.
 
 Here are my directory listings

 docroot= /usr/share/tomcat5/webapps/smsinfo
 ***
 anw-dev:/usr/share/tomcat5/webapps/smsinfo$ ls -laF
 total 20
 drwxr-xr-x  3 anw root 4096 2006-05-19 21:14 ./
 drwxr-xr-x  9 tomcat5 root 4096 2006-05-13 16:10 ../
 -rw-r--r--  1 anw anw   564 2006-05-19 21:20 login.jsp
 drwxr-xr-x  4 anw anw  4096 2006-05-19 21:15 WEB-INF/
 -rw-r--r--  1 anw anw   241 2006-05-19 21:20 welcome.jsp

 
 anw-dev:/usr/share/tomcat5/webapps/smsinfo/WEB-INF$ ls -laF
 total 20
 drwxr-xr-x  4 anw anw  4096 2006-05-19 21:15 ./
 drwxr-xr-x  3 anw root 4096 2006-05-19 21:14 ../
 drwxr-xr-x  3 anw root 4096 2006-05-18 20:27 classes/
 drwxr-xr-x  2 anw root 4096 2006-05-13 15:49 lib/
 -rw-r--r--  1 anw anw   440 2006-05-19 21:18 web.xml

 (lib is empty)
 ***
 anw-dev:/usr/share/tomcat5/webapps/smsinfo/WEB-INF/classes$ ls -laF
 total 12
 drwxr-xr-x  3 anw root 4096 2006-05-18 20:27 ./
 drwxr-xr-x  4 anw anw  4096 2006-05-19 21:15 ../
 drwxr-xr-x  2 anw root 4096 2006-05-18 20:27 UserConfig/
 *
 anw-dev:/usr/share/tomcat5/webapps/smsinfo/WEB-INF/classes/UserConfig$
 ls -laF
 total 12
 drwxr-xr-x  2 anw root 4096 2006-05-18 20:27 ./
 drwxr-xr-x  3 anw root 4096 2006-05-18 20:27 ../
 -rwxr-xr-x  1 anw root 1322 2006-05-19 21:18 login.class*
 *

 Here is the source to login.jsp (located in docroot,
 /usr/share/tomcat5/webapps/smsinfo):

 html
 head
 titleSMS Information Transfer Login Page/title
 meta http-equiv=Content-Type content=text/html;
 charset=iso-8859-1
 /head

 body bgcolor=#FF onload=document.loginForm.username.focus()
 !-- form name=loginForm method=post
 action=/servlet/UserConfig.login --
 form name=loginForm method=post
 action=WEB-INF/classes/UserConfig.login
 pUser Name:input type=text name=username/p
 pPassword:input type=password
 name=password/p
 pinput type=Submit name=Submit/p
 /form
 /body
 /html

 *
 Here is the source to login.class:

 package UserConfig;

 import javax.servlet.*;
 import javax.servlet.http.*;
 import java.io.*;
 import java.util.*;

 public class login extends HttpServlet
 {
 private String target=/welcome.jsp;
 private String getUser(String username, String password)
 {
 return username;
 }
 public void doGet(HttpServletRequest request, HttpServletResponse
 response)
 throws ServletException, IOException
 {
 // If it is a Get request, forward to doPost
 doPost(request, response);
 }
 public void doPost(HttpServletRequest request, HttpServletResponse
 response)
 throws ServletException, IOException
 {
 // Get user name and password:
 String username= request.getParameter(username);
 String password= request.getParameter(password);
 String user= getUser(username, password);
 // Add fake user to the request
 request.setAttribute(USER, user);
 ServletContext context= getServletContext();
 RequestDispatcher dispatcher=
 context.getRequestDispatcher(target);
 //target defined above
 dispatcher.forward(request, response);
 }
 }
 ***
 Here is the source for my web.xml file:

 ?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/j2ee/dtds/web-app_2_3.dtd;

 web-app
 servlet
 servlet-namelogin/servlet-name
 servlet-classUserConfig.login/servlet-class
 /servlet
 servlet-mapping
 servlet-namelogin/servlet-name
 url-pattern/servlet/login/url-pattern
 /servlet-mapping
 /web-app
 ***

 As can be seen, all this is very simple, my very first Tomcat web
 app.  I
 have
 followed the instructions in

 http://tomcat.apache.org/tomcat-5.5-doc/appdev/index.html

 When I go to http://localhost:8180/smsinfo/login.jsp, I get the
 form, input
 some text, then get the following screen from tomcat:

 HTTP Status 404 - /smsinfo/WEB-INF/classes/UserConfig.login

 Type: Status report

 Message: /smsinfo/WEB-INF/classes/UserConfig.login

 Description: The requested resource
 

Re: Directory Structure and Can't Find Resources in Tomcat

2006-05-20 Thread Hassan Schroeder

On 5/19/06, Allen Williams [EMAIL PROTECTED] wrote:


form name=loginForm method=post
action=WEB-INF/classes/UserConfig.login


You can't directly address something under WEB-INF; your action
should be something like `action=/login` with a mapping in your
web.xml like

servlet
  servlet-namelogin/servlet-name
  servlet-classUserConfig.login/servlet-class
/servlet
servlet-mapping
  servlet-namelogin/servlet-name
  url-pattern/login/url-pattern
/servlet-mapping

Note: NO /servlet in there -- read the Tomcat doc or google for
Tomcat invoker servlet to understand why...

HTH,
--
Hassan Schroeder  [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Directory Structure and Can't Find Resources in Tomcat

2006-05-20 Thread Allen Williams
So, I don't need 'action=servlet/login', like the book I'm using said? 
Or, don't need 'action=classes/login', like I might infer?

Thanks, I'll do the google you recommend, try it, and be back with you
in short order (or maybe tomorrow;-).

Thanks again!

-Original Message-
From: Hassan Schroeder [mailto:[EMAIL PROTECTED]
Sent: Saturday, May 20, 2006 2:19 PM
To: Tomcat Users List
Subject: Re: Directory Structure and Can't Find Resources in Tomcat


On 5/19/06, Allen Williams [EMAIL PROTECTED] wrote:

 form name=loginForm method=post
 action=WEB-INF/classes/UserConfig.login

You can't directly address something under WEB-INF; your action
should be something like `action=/login` with a mapping in your
web.xml like

servlet
   servlet-namelogin/servlet-name
   servlet-classUserConfig.login/servlet-class
/servlet
servlet-mapping
   servlet-namelogin/servlet-name
   url-pattern/login/url-pattern
/servlet-mapping

Note: NO /servlet in there -- read the Tomcat doc or google for
Tomcat invoker servlet to understand why...

HTH,
-- 
Hassan Schroeder  [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Directory Structure and Can't Find Resources in Tomcat

2006-05-20 Thread Allen Williams
Sorry, it didn't work.  Once again, in my browser I have:

HTTP Status 404 - /login
Type: Status report
Message: /login
Description: The requested resource (/login) is not available.
Apache Tomcat/5.0
*
Here is the suggested line directly from my login.jsp:

form name=loginForm method=post action=/login
*
Here is my entire web.xml file:

!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
http://java.sun.com/j2ee/dtds/web-app_2_3.dtd;

web-app
servlet
servlet-namelogin/servlet-name
servlet-classUserConfig.login/servlet-class
/servlet
servlet-mapping
servlet-namelogin/servlet-name
!-- url-pattern/servlet/login/url-pattern --
url-pattern/login/url-pattern
/servlet-mapping
/web-app

All the rest (directory structure, etc.) is as in my first post.

-Original Message-
From: Hassan Schroeder [mailto:[EMAIL PROTECTED]
Sent: Saturday, May 20, 2006 2:19 PM
To: Tomcat Users List
Subject: Re: Directory Structure and Can't Find Resources in Tomcat


On 5/19/06, Allen Williams [EMAIL PROTECTED] wrote:

 form name=loginForm method=post
 action=WEB-INF/classes/UserConfig.login

You can't directly address something under WEB-INF; your action
should be something like `action=/login` with a mapping in your
web.xml like

servlet
   servlet-namelogin/servlet-name
   servlet-classUserConfig.login/servlet-class
/servlet
servlet-mapping
   servlet-namelogin/servlet-name
   url-pattern/login/url-pattern
/servlet-mapping

Note: NO /servlet in there -- read the Tomcat doc or google for
Tomcat invoker servlet to understand why...

HTH,
-- 
Hassan Schroeder  [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]