Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jweb-e002
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cristian Caceres
jweb-e002
Commits
ade207a4
Commit
ade207a4
authored
Aug 21, 2019
by
Cristian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inicial proyect
parent
461c21a4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
30 deletions
+54
-30
WebContent/ConversorResultado.jsp
+11
-7
WebContent/Error.jsp
+4
-4
src/servlet/ConversorServlet.java
+39
-19
No files found.
WebContent/ConversorResultado.jsp
View file @
ade207a4
...
...
@@ -10,17 +10,21 @@
integrity=
"sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin=
"anonymous"
>
</head>
<body
class=
"container"
>
<
%
ArrayList
<
Float
>
resultado=(ArrayList
<Float>
) request.getAttribute("resultado");
String tipo =request.getAttribute("P0").toString();
if(tipo.toLowerCase().equals("c")){
<
%
ArrayList
<
Float
>
resultado= new ArrayList
<Float>
();
String tipo="";
if(request.getAttribute("array")!=null
&&
request.getAttribute("P0")!=null){
resultado= (ArrayList
<Float>
) request.getAttribute("array");
tipo =request.getAttribute("P0").toString();
if(tipo.toLowerCase().equals("c")){
tipo=" Celsius";
}else if(tipo.toLowerCase().equals("f")){
}else if(tipo.toLowerCase().equals("f")){
tipo=" Fahrenheit";
}else{
}else{
tipo=" Kelvin";
}
}
%>
<nav
class=
"navbar navbar-expand-lg navbar-light bg-light"
>
...
...
WebContent/Error.jsp
View file @
ade207a4
...
...
@@ -11,7 +11,7 @@
integrity=
"sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin=
"anonymous"
>
</head>
<body>
<body
class=
"container"
>
<nav
class=
"navbar navbar-expand-lg navbar-light bg-light"
>
<a
class=
"navbar-brand"
href=
"#"
>
Menu
</a>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarSupportedContent"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
...
...
@@ -34,10 +34,10 @@
</li>
</div>
</nav>
</body
class="container"
>
<
%
Exception
resultado=
null
;
</body
>
<
%
String
resultado=
""
;
if
(
request
.
getAttribute
("
resultado
")!=
null
){
resultado=
(
Exception
)
request
.
getAttribute
("
resultado
");
resultado=
(
String
)
request
.
getAttribute
("
resultado
");
}
%
>
<h1><
%=
resultado
.
toString
()
%
></h1>
...
...
src/servlet/ConversorServlet.java
View file @
ade207a4
...
...
@@ -41,40 +41,37 @@ public class ConversorServlet extends HttpServlet {
// TODO Auto-generated method stub
doGet
(
request
,
response
);
ArrayList
<
Float
>
resultado
=
new
ArrayList
<
Float
>();
System
.
out
.
println
(
"P1"
);
int
error
=
0
;
try
{
if
(
request
.
getParameter
(
"P1"
)!=
null
&&
request
.
getParameter
(
"P0"
)!=
null
)
{
System
.
out
.
println
(
request
.
getParameter
(
"P0"
).
toString
());
String
p0
=
request
.
getParameter
(
"P0"
).
toString
();
if
(!
"c"
.
equals
(
p0
)||
!
"k"
.
equals
(
p0
)||
!
"f"
.
equals
(
p0
))
{
request
.
setAttribute
(
"resultado"
,
"valor de palo no esperado"
);
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"Error.jsp"
);
if
(
rd
!=
null
)
{
rd
.
forward
(
request
,
response
);
}
System
.
out
.
println
(
request
.
getParameter
(
"P1"
).
toString
());
String
p0
=(
String
)
request
.
getParameter
(
"P0"
);
if
((
"C"
.
equals
(
p0
.
toUpperCase
()))
||
(
"K"
.
equals
(
p0
.
toUpperCase
()))
||
(
"F"
.
equals
(
p0
.
toUpperCase
())))
{
}
else
{
error
=
1
;
}
resultado
=
convertidor
(
request
.
getParameter
(
"P0"
).
toString
(),
Float
.
parseFloat
(
request
.
getParameter
(
"P1"
)));
System
.
out
.
println
(
"aca llego"
);
request
.
setAttribute
(
"P0"
,
request
.
getParameter
(
"P0"
));
request
.
setAttribute
(
"P1"
,
request
.
getParameter
(
"P1"
));
request
.
setAttribute
(
"
resultado
"
,
resultado
);
request
.
setAttribute
(
"
array
"
,
resultado
);
}
else
{
request
.
setAttribute
(
"resultado"
,
"Parametros nulos"
);
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"Error.jsp"
);
if
(
rd
!=
null
)
{
rd
.
forward
(
request
,
response
);
}
error
=
2
;
}
}
catch
(
Exception
e
)
{
// TODO: handle exception
System
.
out
.
println
(
"exploto"
);
request
.
setAttribute
(
"resultado"
,
"el valor no es numerico"
);
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"Error.jsp"
);
if
(
rd
!=
null
)
{
rd
.
forward
(
request
,
response
);
}
error
=
3
;
/*PrintWriter respuesta= response.getWriter();
respuesta.println("<!DOCTYPE html>");
...
...
@@ -91,10 +88,33 @@ public class ConversorServlet extends HttpServlet {
}
finally
{
if
(
error
==
1
)
{
request
.
setAttribute
(
"resultado"
,
"valor de palo no esperado"
);
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"Error.jsp"
);
if
(
rd
!=
null
)
{
rd
.
forward
(
request
,
response
);
}
}
else
if
(
error
==
2
){
request
.
setAttribute
(
"resultado"
,
"Parametros nulos"
);
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"Error.jsp"
);
if
(
rd
!=
null
)
{
rd
.
forward
(
request
,
response
);
}
}
else
if
(
error
==
3
){
request
.
setAttribute
(
"resultado"
,
"el valor no es numerico"
);
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"Error.jsp"
);
if
(
rd
!=
null
)
{
rd
.
forward
(
request
,
response
);
}
}
else
{
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
"/ConversorResultado.jsp"
);
if
(
rd
!=
null
)
{
rd
.
forward
(
request
,
response
);
}
}
PrintWriter
respuesta
=
response
.
getWriter
();
respuesta
.
println
(
"<!DOCTYPE html>"
);
respuesta
.
print
(
"<html>"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment