Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jweb-001
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
Pedro Rolon
jweb-001
Commits
43dbd296
Commit
43dbd296
authored
Nov 16, 2018
by
Pedro Rolon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
se agregó soporte para errores en el conversor
parent
e331f773
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
28 deletions
+23
-28
jweb-e001/WebContent/WEB-INF/web.xml
+1
-24
jweb-e001/src/servlets/Conversor.java
+22
-4
No files found.
jweb-e001/WebContent/WEB-INF/web.xml
View file @
43dbd296
...
...
@@ -9,26 +9,4 @@
<welcome-file>
default.htm
</welcome-file>
<welcome-file>
default.jsp
</welcome-file>
</welcome-file-list>
<servlet-mapping>
<servlet-name>
default
</servlet-name>
<url-pattern>
*.html
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
default
</servlet-name>
<url-pattern>
*.jpg
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
default
</servlet-name>
<url-pattern>
*.png
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
default
</servlet-name>
<url-pattern>
*.css
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
default
</servlet-name>
<url-pattern>
*.js
</url-pattern>
</servlet-mapping>
</web-app>
\ No newline at end of file
</web-app>
jweb-e001/src/servlets/Conversor.java
View file @
43dbd296
...
...
@@ -41,13 +41,31 @@ public class Conversor extends HttpServlet {
String
valorTemperatura
=
request
.
getParameter
(
"valor"
);
String
tipoTemperatura
=
request
.
getParameter
(
"tipo_temperatura"
);
//convertir el valor a double
double
valorTemperaturaDouble
=
Double
.
parseDouble
(
valorTemperatura
);
//Obtiene el writer de la respuesta y la guarda
//en una variable "respuesta"
PrintWriter
respuesta
=
response
.
getWriter
();
PrintWriter
respuesta
=
response
.
getWriter
();
//convertir el valor a double
double
valorTemperaturaDouble
;
try
{
valorTemperaturaDouble
=
Double
.
parseDouble
(
valorTemperatura
);
}
catch
(
Exception
e
){
respuesta
.
println
(
"<!DOCTYPE html>"
);
respuesta
.
print
(
"<html>"
);
respuesta
.
println
(
"<head>"
);
respuesta
.
println
(
"<meta charset=\"UTF-8\">"
);
respuesta
.
println
(
"<title>Convertidor!</title>"
);
respuesta
.
println
(
"</head>"
);
respuesta
.
println
(
"<body>"
);
respuesta
.
println
(
"El valor introducido no es valido"
);
respuesta
.
println
(
"</body>"
);
respuesta
.
println
(
"</html>"
);
return
;
}
//si todo salió bien, va a llegar a esta linea
valorTemperaturaDouble
=
Double
.
parseDouble
(
valorTemperatura
);
double
celsius
=
0
;
double
fahrenheit
=
0
;
...
...
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