aboutsummaryrefslogtreecommitdiff
path: root/src/main/webapp/pages/userIndex.jsp
blob: b06d9662479daa3a855b25daa60d3c22053e1536 (plain) (blame)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<%@page import="models.Monster"%>
<%@page import="java.util.ArrayList"%>
<%@page import="models.CONSTS"%>
<%@page import="java.rmi.Naming"%>
<%@page import="pokemon.IService"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>

<html>
<head>
<meta charset="ISO-8859-1">
<title>User</title>
<style>
	table, th, td {
	  border: 1px solid black;
	  border-collapse: collapse;
	  padding:2px;
	}
</style>
</head>
<body>
<%
boolean isAdmin=(Boolean)session.getAttribute("admin");
if(isAdmin){
	response.sendRedirect("../index.jsp");
}
%>
<a href="logout.jsp">
	<button>Log out</button>
</a>
<h1>Izaberi pokemona</h1>
<br>
<%
	IService service=(IService)Naming.lookup(CONSTS.rmiUrl);
	ArrayList<Monster> monsters=service.getMonsters();
	String username=(String)session.getAttribute("username");
	request.setAttribute("monsters", monsters);
	Monster myMonster=service.getUserMonster(username);
	request.setAttribute("myMonster", myMonster);
%>
Trenutno izabran pokemon: 
<%
	if(myMonster==null)
	{
		%>
		<p style="color:red">Nemate trenutno izabranog pokemon. Morate izabrati pokemona da bi mogli da igrate igru</p>
		<%
	}
	else{
		%>
		<jsp:include page="pokemonViewModel.jsp">
			<jsp:param value="${myMonster.id}" name="monsterId"/>
		</jsp:include>
		<% 
	}
%>
<br><br><br>
<h1>Svi pokemoni</h1>
<table>
<tr>
<th>Ime</th>
<th>Opis</th>
<th>Hp</th>
<th>Slika</th>
<th></th>
</tr>
<c:forEach items="${monsters}" var="item">
<tr>
	<td>
	<c:out value="${item.name}"/>
	</td>
	<td>
	<c:out value="${item.description}"/>
	</td>
	<td>
	<c:out value="${item.hp}"/>
	</td>
	<td>
	<img style="height: 50px" src="data:image/*;base64, ${item.base64Image }" />
	</td>
	<td>
	<a href="choosePokemon.jsp?monsterId=${item.id}">
	<button>Izaberi</button>
</a>
	</td>
</tr> 
</c:forEach>

</table>
</body>
</html>