During the webpage posting to the server, the textboxes,the uploaded files is cleared(because the server recreating the webpage,my solution to this problem is storing varibles values in session varibles and retriving the varibles values after page recreation...I want some webdeveloper to confirm me the correctness of this solution or advice me another way of maintaining varibles values.
thanks for all.

Dani AI

Generated

Sessions will work for preserving simple form values across a server-side postback, but there are important trade-offs and other patterns to consider.

Browsers will not repopulate file inputs for security, so you cannot rely on client-side rehydration of an uploaded file after a full postback. A common, robust approach is a two-step workflow: upload the file first to a temporary server location (store only a small temp-ID in session or a hidden field), then submit the rest of the form referencing that temp-ID. That keeps session memory small and avoids forcing the user to reselect files. See the browser behaviour for file inputs on MDN: input type=file.

If you keep values server-side, avoid storing large blobs in session (use a temp store, S3, or disk) and plan for multi-server scaling (distributed session store like Redis or DB). Follow session best practices for security and timeouts: OWASP Session Management Cheat Sheet.

For smoother UX, consider:

  • Client-side validation and localStorage/sessionStorage for non-sensitive fields so users don’t lose typed data (Using the Web Storage API).
  • AJAX (or a small fetch/FormData upload) for files to avoid full page reloads.
  • PRG (Post/Redirect/Get) to avoid duplicate submissions and allow safe redirects after processing ().

Minimal AJAX file-upload pattern (illustrative):

const fd = new FormData();
fd.append('file', fileInput.files[0]);
fetch('/upload-temp', { method: 'POST', body: fd })
  .then(r => r.json())
  .then(j => { /* set hidden input tempId = j.id before final submit */ });

pointed toward server-side validation and flow control; combine that with the temporary-upload + temp-ID pattern for reliable handling of file inputs and to keep session use efficient.

Recommended Answers

All 2 Replies

moved

You question is not clear but I guess you asking about keeping data recieved from user through web form and reusing them later
This is similar across diferent languages
1) Retrive data from form and validate them either directly on the page if you have algoritm in place or in servlet (in Java web development)
2) Servlet store data in sessions and call next page (alternatively return to original page)
3) Next page request session and use it as necessary

Hope this is what you been looking for

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.