Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
health-search-tools
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jennifer Mankoff
health-search-tools
Commits
b3d1d253
Commit
b3d1d253
authored
11 years ago
by
Cheng Guo
Browse files
Options
Downloads
Patches
Plain Diff
Improved efficiency while logging
parent
bbbb6204
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Survey/src/java/servlet/Ml1.java
+23
-22
23 additions, 22 deletions
Survey/src/java/servlet/Ml1.java
Survey/src/java/servlet/Ml3.java
+17
-16
17 additions, 16 deletions
Survey/src/java/servlet/Ml3.java
with
40 additions
and
38 deletions
Survey/src/java/servlet/Ml1.java
+
23
−
22
View file @
b3d1d253
...
...
@@ -50,7 +50,6 @@ public class Ml1 extends HttpServlet {
Integer
urlNum
=
Integer
.
parseInt
(
request
.
getParameter
(
"urlNum"
));
HttpSession
session
=
request
.
getSession
(
true
);
String
currentUser
=
(
String
)
session
.
getAttribute
(
"currentSessionUser"
);
System
.
out
.
println
(
currentUser
);
String
url
=
(
String
)
session
.
getAttribute
(
"1url"
+
urlNum
+
currentUser
);
URL
MLurl
=
new
URL
(
url
);
InputStream
is
=
(
InputStream
)
MLurl
.
getContent
();
...
...
@@ -69,30 +68,32 @@ public class Ml1 extends HttpServlet {
String
info
=
(
String
)
jsonObj
.
get
(
"infoLinks"
);
out
.
println
(
message
);
//write info and percentexper to the logging file
String
path
=
request
.
getRealPath
(
"/User"
);
String
oldFileName
=
path
+
"/"
+
currentUser
+
".txt"
;
String
tempFileName
=
path
+
"/"
+
"temp.txt"
;
BufferedReader
newBr
;
BufferedWriter
bw
;
String
newLine
;
newBr
=
new
BufferedReader
(
new
FileReader
(
oldFileName
));
bw
=
new
BufferedWriter
(
new
FileWriter
(
tempFileName
));
if
(!
"null"
.
equals
(
currentUser
))
{
while
((
newLine
=
newBr
.
readLine
())
!=
null
)
{
if
(
newLine
.
contains
(
url
))
{
newLine
=
newLine
.
replace
(
"<info></info>"
,
"<info>"
+
info
+
"</info>"
).
replace
(
"<percentexper></percentexper>"
,
"<percentexper>"
+
percentexper
+
"</percentexper>"
);
if
(
currentUser
!=
null
)
{
//write info and percentexper to the logging file
String
path
=
request
.
getRealPath
(
"/User"
);
String
oldFileName
=
path
+
"/"
+
currentUser
+
".txt"
;
String
tempFileName
=
path
+
"/"
+
"temp.txt"
;
BufferedReader
newBr
;
BufferedWriter
bw
;
String
newLine
;
newBr
=
new
BufferedReader
(
new
FileReader
(
oldFileName
));
bw
=
new
BufferedWriter
(
new
FileWriter
(
tempFileName
));
if
(!
"null"
.
equals
(
currentUser
))
{
while
((
newLine
=
newBr
.
readLine
())
!=
null
)
{
if
(
newLine
.
contains
(
url
))
{
newLine
=
newLine
.
replace
(
"<info></info>"
,
"<info>"
+
info
+
"</info>"
).
replace
(
"<percentexper></percentexper>"
,
"<percentexper>"
+
percentexper
+
"</percentexper>"
);
}
bw
.
write
(
newLine
+
"\n"
);
}
bw
.
write
(
newLine
+
"\n"
);
}
}
newBr
.
close
();
bw
.
close
();
newBr
.
close
();
bw
.
close
();
File
oldFile
=
new
File
(
oldFileName
);
oldFile
.
delete
();
File
newFile
=
new
File
(
tempFileName
);
newFile
.
renameTo
(
oldFile
);
File
oldFile
=
new
File
(
oldFileName
);
oldFile
.
delete
();
File
newFile
=
new
File
(
tempFileName
);
newFile
.
renameTo
(
oldFile
);
}
}
finally
{
out
.
close
();
}
...
...
This diff is collapsed.
Click to expand it.
Survey/src/java/servlet/Ml3.java
+
17
−
16
View file @
b3d1d253
...
...
@@ -68,29 +68,30 @@ public class Ml3 extends HttpServlet {
String
info
=
(
String
)
jsonObj
.
get
(
"infoLinks"
);
out
.
println
(
message
);
String
path
=
request
.
getRealPath
(
"/User"
);
String
oldFileName
=
path
+
"/"
+
currentUser
+
".txt"
;
String
tempFileName
=
path
+
"/"
+
"temp.txt"
;
BufferedReader
newBr
;
BufferedWriter
bw
;
String
newLine
;
newBr
=
new
BufferedReader
(
new
FileReader
(
oldFileName
));
bw
=
new
BufferedWriter
(
new
FileWriter
(
tempFileName
));
if
(!
"null"
.
equals
(
currentUser
))
{
if
(
currentUser
!=
null
)
{
String
path
=
request
.
getRealPath
(
"/User"
);
String
oldFileName
=
path
+
"/"
+
currentUser
+
".txt"
;
String
tempFileName
=
path
+
"/"
+
"temp.txt"
;
BufferedReader
newBr
;
BufferedWriter
bw
;
String
newLine
;
newBr
=
new
BufferedReader
(
new
FileReader
(
oldFileName
));
bw
=
new
BufferedWriter
(
new
FileWriter
(
tempFileName
));
while
((
newLine
=
newBr
.
readLine
())
!=
null
)
{
if
(
newLine
.
contains
(
url
))
{
newLine
=
newLine
.
replace
(
"<info></info>"
,
"<info>"
+
info
+
"</info>"
).
replace
(
"<percentexper></percentexper>"
,
"<percentexper>"
+
percentexper
+
"</percentexper>"
);
}
bw
.
write
(
newLine
+
"\n"
);
}
}
newBr
.
close
();
bw
.
close
();
newBr
.
close
();
bw
.
close
();
File
oldFile
=
new
File
(
oldFileName
);
oldFile
.
delete
();
File
newFile
=
new
File
(
tempFileName
);
newFile
.
renameTo
(
oldFile
);
File
oldFile
=
new
File
(
oldFileName
);
oldFile
.
delete
();
File
newFile
=
new
File
(
tempFileName
);
newFile
.
renameTo
(
oldFile
);
}
}
finally
{
out
.
close
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment