I WILL TRY AGAIN TO WRITE MY CODE , HOPLY IT WILL BE MORE CLEARLY.
The jsp code is:
1..<%@ page language="java" contentType="text/html; charset=windows-1255"
2.. pageEncoding="windows-1255"%>
3..<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4..<html>
5..<head>
6..<meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
7.. <title>Insert title here</title>
8--</head>
9--<body>
10--
welcome to our bank
11--<form action=TestUser3 METHOD="post">
12--<input type="radio" name="kaspomat" value="a1" CHECKED>
13--radio button 1
14--
15--
16--<input type="radio" name="kaspomat" value="a10" >
17--radio button 2
18--
19--
20--<input type="radio" name="kaspomat" value="a20" >
21--radio button 3
22--
23--
24--<input type="submit" VALUE="Submit" >
25--
26--
27--td> what your choise </td>
and the servlet is:
1.package alona;
2.import java.io.IOException;
3.import valueObjects.User;
4.* Servlet implementation class TestUser3
5.public class TestUser3 extends HttpServlet {
6.
7. private static final long serialVersionUID = 1L;
8. private Object user;
9. // TODO Auto-generated constructor stub
10. * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
11. public void doGet(HttpServletRequest request, HttpServletResponse response)throws javax.servlet.ServletException,
12. java.io.IOException {
13. // TODO Auto-generated method stub
14. // try {
15. // super.doGet(request, response);
16. // } catch (ServletException e) {
// TODO Auto-generated catch block
17. // e.printStackTrace();
18. // } catch (IOException e) {
// TODO Auto-generated catch block
19. // e.printStackTrace();
20. // doGet( request, response);
}
21.
22.// }
/**
23. * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
24. */
25. protected void doPost(HttpServletRequest request1, HttpServletResponse response1) throws ServletException, IOException {{
26. // TODO Auto-generated method stub
27. // try {
28. // super.doPost(request1, response1);
29. // } catch (ServletException e) {
// TODO Auto-generated catch block
30. // e.printStackTrace();
31. // catch (IOException e) {
// TODO Auto-generated catch block
32. // e.printStackTrace();
33. }
34. // TODO Auto-generated catch block
35. doPost1(request1, response1, null, null);
36. // TODO Auto-generated catch block
37. }
38.
void doPost1 (HttpServletRequest request1, HttpServletResponse response1,String username)throws
39.
ServletException,IOException {
40. String kaspomat1=(String)request1.getParameter("radios");
41.
42. try {
if((request1.getParameterValues("radios")) != null) {
43.
44. if(request1.getParameterValues("radios").equals("a1")) {
45. javax.servlet.RequestDispatcher rd = this.getServletContext().getRequestDispatcher
46. ("/indexa1.jsp");
47. rd.forward(request1, response1);
48. }
49. if(request1.getParameterValues("radios").equals("a10")) {
50. response1.sendRedirect("http://www.ynet.il");
51. }
52.
53. if(request1.getParameterValues("radios").equals("a20")) {
54. response1.sendRedirect("http://www.nrg.il");
55. }
56. }
else {
57. javax.servlet.RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/indexwrong.jsp");
58. rd.forward(request1, response1);
59. }
}
60. catch (Exception e) {
61. e.printStackTrace();
62. }
63.
64. }
65.}