For lengthy listings, leave the environment \begin and \end on their own lines. For short, in-line listings, use \lstinline (already defined). Here's an example of their usages:

\documentclass{article}
\usepackage{listings}% http://ctan.org/pkg/listings
\lstset{basicstyle=\ttfamily,breaklines=true}
\begin{document}
\begin{lstlisting}
http://www.victim.com/cms/login.php?..
\end{lstlisting}
Some text and \lstinline!http://www.victim.com/cms/login.php?..! and some more text.
\end{document}
The listings documentation uses the following terminology (section 4.2 Typesetting listings, p 25-26):
- Code snippets:
\lstinline
- Displayed code:
lstlisting environment
- Stand alone files:
\lstinputlisting
Regarding the use of the displayed code lstlisting environment, it also states (p 26):
In contrast to the environment of the verbatim package, LaTeX code
on the same line and after the end of environment is typeset
respectively executed.
This allows you to use
\begin{lstlisting}
http://www.victim.com/cms/login.php?..\end{lstlisting}
but not
\begin{lstlisting}http://www.victim.com/cms/login.php?..
\end{lstlisting}
Regardless, I don't see the need to keep code listings and their enclosed environment definitions on the same line, so even the allowed use above could benefit from putting \end{lstlisting} on its own line.
\lstinlinerather than the environment form. – Werner Jan 23 '13 at 18:16