<% if (request.getParameter ("action") == null) { %> Internet Psychologist

Welcome to the Internet Psychologist!

The psychologist can see you now...please enter your name and click the Introduce button.

" method="POST">

Please enter your name:

<% } else if (request.getParameter ("action").equals ("goto_question")) { %> Internet Psychologist <% String name = request.getParameter ("name"); if (name == null) name = (String) session.getAttribute ("name"); else session.setAttribute ("name", name); %>

Hello, <%= name %>

<% if (request.getParameter ("statement") == null) { %>

Enter a statement in the edit field below about how you are feeling.

<% } else { %>

<%= processStatement (request.getParameter ("statement"))%>

If you would like to continue talking with the psychologist enter another statement

<% Integer num = (Integer) session.getAttribute ("num_statements"); if (num != null) session.setAttribute("num_statements", new Integer (num.intValue() + 1)); else session.setAttribute("num_statements", new Integer (1)); } %>
" method="post">

Statement:

">
<% } else if (request.getParameter ("action").equals ("goto_statistics")) { %> Internet Psychologist Statistics

Your Psychologist Statistics:

<% String name = request.getParameter ("name"); Integer number = (Integer) session.getAttribute ("num_statements"); int num = 0; if (number != null) num = number.intValue (); %>

You have made <%= num %> statements to the psychologist.

">
<% } else { /* An incorrect action! */ %> Internet Psychologist

Sorry, the Psychologist is having a bad day.

The action was: <%= request.getParameter ("action") %>

<% } %> <%! /* Private methods */ private String processStatement (String statement) { return "How do you feel when you say, \"" + statement + "\""; } %>