Send servlet back to Java page or back to html page
I have a form which submits to a Servlet from which the Servlet responds by showing the user name and thanks for the submission.
I then want the user to either be able to go back to the main class activity or be able to go back to a start jsp page. would be better to go to the main class but if this is not possible just how to put the link in the following to go back to the main page:
out.println("<html>");
out.println("<body>");
out.println("Thanks" + " " + User + " " + "for submitting your request<br>" );
out.println("Your request will be in a waiting list so please be patient");
out.println("</body></html>");
开发者_运维问答
Also how can I change the text size as this shows up very small on the page.
Thanks
You can use the HTML <a>
element to show a link on the webpage.
<a href="http://stackoverflow.com">A link to stackoverflow.com</a>
You can use CSS font-size
property to change the font size of the webpage.
<style>
body {
font-size: 150%;
}
</style>
See also:
- HTML tutorial/reference
- CSS tutorial/reference
- Web development, what skills do I need?
Note that this is not really related to Java/Servlets and that HTML technically belongs in a JSP, not a Servlet. See also our Servlets wiki page.
In addition to the correct answer given by BalusC, I would like to add that Servlets are not really intended (anymore) for what you are doing here.
If you want to use Servlets/JSP you'd best do the processing of your form in the servlet, and then forward or redirect (whatever is most appropriate) to a JSP. This JSP would then contain the "Thanks..." text.
To forward use:
request.getRequestDispatcher("someURL").forward(request, response);
To redirect use:
response.sendRedirect("someUrl")
Since you need access to User
here, putting this object in the request scope and then forwarding would be most appropriate.
I then want the user to either be able to go back to the main class activity or be able to go back to a start jsp page. would be better to go to the main class but if this is not possible just how to put the link in the following to go back to the main page:
Add the url pattern for your main servlet as a link
out.println("<html>");
out.println("<body>");
out.println("Thanks" + " " + User + " " + "for submitting your request<br>" );
out.println("Your request will be in a waiting list so please be patient");
out.println("<a href='http://www.yourdomain.com/urlpattern'>Back to Main Page</a>");
out.println("</body></html>");
For more information on <a>
tag see Hyper Link
精彩评论