Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jweb-e001
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
Matias Ferreira
jweb-e001
Commits
2f484668
Commit
2f484668
authored
Sep 25, 2020
by
Matias Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cambie tipo de dato de factorial de int a BigInteger para evitar desbordamento
parent
c8659dc5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
10 deletions
+15
-10
WebProjectTest/WebContent/index.html
+3
-3
WebProjectTest/build/classes/com/roshka/webprojecttest/servlets/FactorialServlet.class
+0
-0
WebProjectTest/src/com/roshka/webprojecttest/servlets/FactorialServlet.java
+12
-7
No files found.
WebProjectTest/WebContent/index.html
View file @
2f484668
...
@@ -8,9 +8,9 @@
...
@@ -8,9 +8,9 @@
<body>
<body>
<p>
hola mundos
</p>
<p>
hola mundos
</p>
<ol>
<ol>
<li><a
href=
"http://localhost:8080/
WebProjectTest
/tabla-multiplicar"
>
aprende a multiplicar!
</a></li>
<li><a
href=
"http://localhost:8080/
JWeb-e001
/tabla-multiplicar"
>
aprende a multiplicar!
</a></li>
<li><a
href=
"http://localhost:8080/
WebProjectTest
/factorial"
>
aprende a factorializar!
</a></li>
<li><a
href=
"http://localhost:8080/
JWeb-e001
/factorial"
>
aprende a factorializar!
</a></li>
<li><a
href=
"http://localhost:8080/
WebProjectTest
/show-me-the-bits"
>
aprender conversion decimal/binario!
</a></li>
<li><a
href=
"http://localhost:8080/
JWeb-e001
/show-me-the-bits"
>
aprender conversion decimal/binario!
</a></li>
</ol>
</ol>
</body>
</body>
...
...
WebProjectTest/build/classes/com/roshka/webprojecttest/servlets/FactorialServlet.class
View file @
2f484668
No preview for this file type
WebProjectTest/src/com/roshka/webprojecttest/servlets/FactorialServlet.java
View file @
2f484668
package
com
.
roshka
.
webprojecttest
.
servlets
;
package
com
.
roshka
.
webprojecttest
.
servlets
;
import
java.math.BigInteger
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
...
@@ -15,6 +16,7 @@ public class FactorialServlet extends HttpServlet {
...
@@ -15,6 +16,7 @@ public class FactorialServlet extends HttpServlet {
protected
void
doGet
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
protected
void
doGet
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
throws
ServletException
,
IOException
{
{
System
.
out
.
println
(
"dentro del doGet"
);
PrintWriter
pw
=
new
PrintWriter
(
resp
.
getOutputStream
());
PrintWriter
pw
=
new
PrintWriter
(
resp
.
getOutputStream
());
Boolean
valido
=
true
;
Boolean
valido
=
true
;
String
parametro
=
req
.
getParameter
(
"number"
);
String
parametro
=
req
.
getParameter
(
"number"
);
...
@@ -43,9 +45,11 @@ public class FactorialServlet extends HttpServlet {
...
@@ -43,9 +45,11 @@ public class FactorialServlet extends HttpServlet {
negative
(
pw
);
negative
(
pw
);
}
}
else
{
else
{
long
facto
=
1
;
BigInteger
facto
=
BigInteger
.
ONE
;
for
(
long
i
=
2
;
i
<=
numero
;
i
++)
for
(
Integer
i
=
2
;
i
<=
numero
;
i
++)
{
facto
*=
i
;
facto
=
facto
.
multiply
(
new
BigInteger
(
i
.
toString
()));
System
.
out
.
printf
(
"factoActual[%d]: "
,
i
,
facto
);
}
factoDisplay
(
pw
,
numero
,
facto
);
factoDisplay
(
pw
,
numero
,
facto
);
}
}
}
}
...
@@ -53,7 +57,8 @@ public class FactorialServlet extends HttpServlet {
...
@@ -53,7 +57,8 @@ public class FactorialServlet extends HttpServlet {
pw
.
close
();
pw
.
close
();
}
}
void
factoDisplay
(
PrintWriter
pw
,
Integer
numero
,
Long
facto
)
{
void
factoDisplay
(
PrintWriter
pw
,
Integer
numero
,
BigInteger
facto
)
{
System
.
out
.
println
(
"dentro del factoDisplay"
);
pw
.
write
(
"<html>"
pw
.
write
(
"<html>"
+
"<head>"
+
"<head>"
+
"<title>Hola, bienvenidos al factorializador</title>"
+
"<title>Hola, bienvenidos al factorializador</title>"
...
@@ -61,13 +66,13 @@ public class FactorialServlet extends HttpServlet {
...
@@ -61,13 +66,13 @@ public class FactorialServlet extends HttpServlet {
+
"<body>"
+
"<body>"
+
"<h1>Soy un generador de factorial de numeros</h1>"
+
"<h1>Soy un generador de factorial de numeros</h1>"
+
"<div>"
+
"<div>"
+
"<form action=\"factorial
-response\"
>"
+
"<form action=\"factorial
\" method=\"get\"
>"
+
"Introduzca el numero: <input type=\"text\" name=number><br>"
+
"Introduzca el numero: <input type=\"text\" name=number><br>"
+
"<input type=\"submit\">"
+
"<input type=\"submit\">"
+
"</form>"
+
"</form>"
+
"</div>"
+
"</div>"
+
"<div>"
+
"<div>"
+
"<p>El factorial de "
+
numero
+
" es: "
+
facto
+
"</p>"
+
"<p>El factorial de "
+
numero
+
" es: "
+
facto
.
toString
()
+
"</p>"
+
"</div>"
+
"</div>"
+
"</body>"
+
"</body>"
+
"</html>"
);
+
"</html>"
);
...
@@ -112,7 +117,7 @@ public class FactorialServlet extends HttpServlet {
...
@@ -112,7 +117,7 @@ public class FactorialServlet extends HttpServlet {
+
"<body>"
+
"<body>"
+
"<h1>Soy un factorializador</h1>"
+
"<h1>Soy un factorializador</h1>"
+
"<div>"
+
"<div>"
+
"<form action=\"factorial
-response\"
>"
+
"<form action=\"factorial
\" method=\"get\"
>"
+
"Introduzca el numero: <input type=\"text\" name=number><br>"
+
"Introduzca el numero: <input type=\"text\" name=number><br>"
+
"<input type=\"submit\">"
+
"<input type=\"submit\">"
+
"</form>"
+
"</form>"
...
...
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