Suicide should be avoided in all circumstances since it is equivalent to
rejecting the basic scheme of the Almighty according to which he has created man
to test him through good and evil circumstances.
One should also remember that the Almighty has specifically mentioned in the
Qur’ān that He never burdens a person with a responsibility he cannot bear
.So however tough be the circumstances, a person should boldly face them knowing
that they have been ordained for Him by the Almighty, and that he has also been
equipped with the required resilience by the Almighty to face them.
As regards the first situation you have mentioned, I think
that instead of ending his life the soldier should wait to see what his enemies
do with him. If he is forced to reveal state secrets or even threatened with
death, he can refuse and even let them take his life. In this way, he
will die the death of a martyr and shall duly be rewarded in the Hereafter.
In the second case also, the lady should not end her life.
She should boldly face the consequences of the heinous deed. I know that this is
easier said than done, and that it is very difficult to bear the aftermath of
such an incident, but then this is a form of trial and test from the Almighty.
By patiently bearing such a great trial, a lady can earn for herself a very high
reward in the Hereafter.
This is what my understanding of Islam says. However, if in
the two situations that you have described the soldier and the girl do commit
suicide, the Almighty might treat them leniently considering the compelling
circumstances. Nevertheless, this is what the Almighty might to do. His servants
should always try to go through the test they have been put through -- however
severe it may be.