Results 1 to 4 of 4
- 03-29-2009, 08:38 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 25
- Rep Power
- 0
- 03-30-2009, 03:23 PM #2
Member
- Join Date
- Mar 2009
- Posts
- 1
- Rep Power
- 0
Java Code:[U]SaveToDB.jsp[/U] <form method='post' action='SaveToDB.jsp'> <input type='text' name='name'/> <input type='submit' name='Submit' value='Send'/> </form> <% String name = request.getParameter("name"); if(name!=null) { enterIntoDB(name); } %> <%= valueFromDB() %> <%! static public String valueFromDB() { String values = {code for retreiving name from DB } return values; } static public String enterIntoDB(String name) { {code for entering name into DB } return values; } %>
- 04-02-2009, 04:30 PM #3
Member
- Join Date
- Mar 2008
- Posts
- 25
- Rep Power
- 0
so i see the form method sends it to same .jsp page and the request.getParam picks it back up and
sends to db if not null, then calls the method to retrieve it...thanks, i'll try this out
- 04-02-2009, 06:04 PM #4
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
what keycode says is generally the behavior you want: if form is submitted, do one task. if form isn't submitted, do another task.
however, i think that it's better practice to have jsp's only outputting information. forms should post to servlets (not jsp's), which should process information and forward to the jsp for whatever the user sees. just my opinion though
Similar Threads
-
how to connect form to another form in netbeans5.5
By Shivraj in forum AWT / SwingReplies: 1Last Post: 03-17-2009, 09:01 AM -
[SOLVED] How to close the current form when i open a new form?
By tpyq in forum NetBeansReplies: 6Last Post: 11-28-2008, 06:55 AM -
how to take query results to a jlist!!
By themburu in forum JDBCReplies: 1Last Post: 06-07-2008, 10:51 AM -
how to take query results to a jlist!!
By themburu in forum New To JavaReplies: 3Last Post: 06-07-2008, 10:45 AM -
1 form 2 servlets
By sandor in forum Java ServletReplies: 2Last Post: 01-22-2008, 10:47 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks