Let $u(x) \in H^1\_0$ is a complex function in sobolev space extension by zero.  

How to find $J'(u)$ for
$$
J(u)= \int\limits\_0^l |u(x)|^2\operatorname{d\!}x\;??
$$
In $L\_2$ it's easy:
$$
J'(u) = \left(\int\limits\_0^l|u(x)|^2 \operatorname{d\!}x\right)'=\big(\|u(x)\|^2\big)'= 2 u(x),
$$
but it does not work with $H^1\_0$, where
$$
\|u(x)\|^2\_{H^1\_0} = \int\limits\_0^l |u'(x)|^2 \operatorname{d\!}x
$$



Derivative in Sobolev space extended by zero
We shall assume that $l\in(0,\infty)$, so that for any $h\in H\_0^1$ we have
$$\int\_0^l|h|^2=\int\_0^l dx\,\Big|\int\_0^x h'\Big|^2 
\le\int\_0^l dx\,\Big(\int\_0^l|h'|\Big)^2 \\ 
\le\int\_0^l dx\,l\,\int\_0^l|h'|^2=l^2\|h\|^2\_{H\_0^1}. \tag{1}\label{1}$$


Next, for any $u$ and $h$ in $H\_0^1$, in view of \eqref{1},
$$J(u+h)-J(u)-2\int\_0^l\Re(\bar uh)=\int\_0^l|h|^2=o(\|h\|\_{H\_0^1})$$
as $\|h\|\_{H\_0^1}\to0$. So, the ([Fréchet](https://en.wikipedia.org/wiki/Fr%C3%A9chet_derivative#Definition)) derivative $J'(u)$ of $J$ at $u\in H\_0^1$ is the linear functional on $H\_0^1$ given by the formula
$$J'(u)(h)=2\int\_0^l\Re(\bar uh)$$
for $h\in H\_0^1$.


