  A numerical study of the nonlinear Schr\"odinger (NLS) equation subject to
homogeneous Dirichlet, Neumann and Robin boundary conditions in the finite line
is presented. The results are compared with both the exact analytical ones for
the initial-value problem (IVP) of the NLS equation and the numerical ones for
periodic boundary conditions. It is shown that initial solutions obtained by
truncating the exact N-soliton solution of the IVP of the NLS equation into a
finite interval develop solitary waves that behave as solitons, even after
collisions with the boundaries. For periodic and homogeneous Dirichlet and
Neumann boundary conditions, it is observed that the interaction between
solitons and boundaries is equivalent to the collision between solitons in IVP
or quarterplane problems. It is shown that for homogeneous Robin boundary
conditions, boundary layers that trap and delay the soliton are formed at the
boundaries. Phase diagrams for the soliton amplitude at the boundary points and
for the soliton's maximum amplitude show a recurrent phenomenon, and are
similar to those of the cubic Duffing equation. It is also shown that the phase
diagrams are strong functions of the parameter that defines the Robin boundary
conditions. A method of images, similar to the one used in potential theory, is
developed for the NLS equation in the quarterplane with homogeneous Dirichlet
and Neumann boundary conditions at the finite boundary.
