-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProg03.java
77 lines (65 loc) · 2.46 KB
/
Prog03.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//a servlet processes multiple values sent by html form for a single html element
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Prog03 extends HttpServlet
{
//as data is sent via doPost() override the doPost()
public void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException
{
//set res type
res.setContentType("text/html");
PrintWriter pw = res.getWriter();
int cost=0;
pw.println("<html><body>");
//following method returns the array of String
String[] arr_dests = req.getParameterValues("dests");
//validation
if(arr_dests==null)
pw.println("<h3>Please select at least on destination</h3><p>");
else
{
for(int i=0;i<arr_dests.length;i++)
{
if(arr_dests[i].equalsIgnoreCase("delhi"))
{
pw.println("<b>Delhi</b><p>");
pw.println("<b>Stay :- </b><i>2 days @ <a href='http://www.hotelholidayinn.com'>Hotel Holiday Inn</a></i><p>");
pw.println("<bPlaces to visit :- </b><i>Lal Fort,Qutub Minar,Sansad Bhavan...</i><p>");
cost+=2000;
}
else if(arr_dests[i].equalsIgnoreCase("agra"))
{
pw.println("<b>Agra</b><p>");
pw.println("<b>Stay :- </b><i>3 days @ <a href='http://www.hotelholidayfarm.com'>Hotel Holiday Farm</a></i><p>");
pw.println("<bPlaces to visit :- </b><i>Taj Mahal, UP jail, Muslim Emporer Palace...</i><p>");
cost+=3000;
}
else if(arr_dests[i].equalsIgnoreCase("jaipur"))
{
pw.println("<b>Jaipur</b><p>");
pw.println("<b>Stay :- </b><i>3 days @ <a href='http://www.hotelpalace.com'>Hotel Palace</a></i><p>");
pw.println("<bPlaces to visit :- </b><i>Hawa Mahal, King's Palace, Forts...</i><p>");
cost+=5000;
}
else if(arr_dests[i].equalsIgnoreCase("nainital"))
{
pw.println("<b>Nainital</b><p>");
pw.println("<b>Stay :- </b><i>2 days @ <a href='http://www.hotellakeview.com'>Hotel Lakeview</a></i><p>");
pw.println("<bPlaces to visit :- </b><i>Boating,River rafting...</i><p>");
cost+=4000;
}
else
{
pw.println("<b>Amritsar</b><p>");
pw.println("<b>Stay :- </b><i>3 days @ <a href='http://www.hoteludtapunjab.com'>Hotel Udta Punjab</a></i><p>");
pw.println("<bPlaces to visit :- </b><i>Jallianwala Baug,How farmers peacefully protest...</i><p>");
cost+=5000;
}
}//end of loop
pw.println("<h3>Total tour cost is Rs "+cost +" </h3><p>");
}
pw.println("</body></html>");
pw.close();
}
}