1

my motive is data flow from modify.jsp to modifysummary.jsp then to servlet to update details but i dont want to use scriptlets in my jsp page.

modify.jsp

<form action="modifysummary.jsp">
<table border="1">

<tr>
<td><label>FirstName</label></td>
<td><input type="text" name="firstname" value="<%=bean.getFirstname() %>"></td>
</tr>
<tr>
<td><label>Surname</label></td>
<td><input type="text" name="surname"  value="<%=bean.getSurname() %>" ></td>
</tr>

</form>

modifysummary.jsp

<table>
<tr >
<th>Employee Details</th>
</tr>


<tr>
<td>First Name</td>
<td><%=request.getParameter("firstname") %></td>
</tr>

<tr>
<td>Surname</td>
<td><%=request.getParameter("surname") %></td>
</tr>

<tr>
<td><input type="button" value="BACK" onclick="javascript:history.go(-1)"></td>
<td><input type="submit" value="Modify" name="Modify"></td>
</tr>

</table>

i have written this code inside a form,on clicking the modify button the data should go to servlet in a bean but how to do that.

Mayank
  • 25
  • 5
  • Try RequestDispatcher, Reference http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/RequestDispatcher.html – Sivakumar Jul 19 '14 at 06:38
  • @Sivakumar can you explain me in detail. I can use forward function from one servlet to another but not from one jsp to servlet – Mayank Jul 19 '14 at 07:08
  • Yeah it's possible to use RequestDispatcher from jsp to servlet. FYI: JSP can be compiled into Java Servlets. – Sivakumar Jul 19 '14 at 09:51

1 Answers1

1

i think this is not possible without using scriptlets in your modifysummary.jsp . you must set your username and password into request attributes

 using  request.setattribute();

and get them in servlet

 using  request.getattribute();

why you don't want to use scriptlets.

and if you want to use requestdispatcher you have to write all that in scriptlets

Prikshit
  • 304
  • 2
  • 12
  • using scriptlets is a bad way of programming more over we cannot handle exceptions ..i have shown only username password but there is too much . – Mayank Jul 19 '14 at 07:36
  • i know this is bad way if you don't want to do this you must learn jsp expression language – Prikshit Jul 19 '14 at 07:54
  • http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files must read this link – Prikshit Jul 19 '14 at 09:48