I am doing program that use prolog to be integrated with HTML and currently stuck at understanding HTTPSESSION in prolog and want to create same function as the JSP below.
HTML input from user:
`<form action="page2.jsp" method="post">
<label>Name:</label>
<input type="text" name="patientname" placeholder="Name">
<input type="submit" value="Next">
</form>`
JSP taking input from HTML:
`<%
String name = request.getParameter("patientname");
session.setAttribute("patientname", name);
%>`
anyone can help? I already seen the http://www.swi-prolog.org/pldoc/man?section=httpsession but still cant understand how to implement the code in prolog.
http_session_asserta(patientname(Name))to add that fact to the session. Later you'd obtain it withhttp_session_data(patientname(Name))to unifyNamewith the current session's patient name. - Daniel Lyonshttp_parameters(Request, _, [form_data(Values)]), member(patientname=PatientName, Values).- Daniel Lyonsasserta/1andassert/1. The former is standard, because you can assert multiple facts with the same arity into the database, theasuffix says "at the beginning of the database" (i.e. before the other facts you already have) versuszmeaning "at the end" (i.e. after the others). I generally avoidassert/1because it is non-standard and leaves the question open. If you don't want your old data replaced, check for it before asserting it. That's just programming. - Daniel Lyonspage_content(Request) --> { http_parameters(Request,[patient(Patient,[optional(true)])]), http_session_asserta(-Patient) },Here I had insert first form value to the asserta/1 in next_page.pl and later I insert second form value to the asserta/1 in next_page2.plpage_content(Request) --> { http_parameters(Request,[age(Age,[optional(true)])]), http_session_asserta(-Age), http_session_data(Patient) },.When I had enter new value to asserta/1 the value will read the age value instead. Or is it another way I can use http_session_data() to get both value. - beginner