• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

looks like I can have 2 html forms with separate submits, but not 3??!!!

Felecha

Golden Member
Trying to learn my way into writing a web app with J2EE, and I've run into a BIG roadblock. I've been learning the necessary html as I go along. I was delighted to find out that for a situation where I have 2 frames on a page, I could have 2 separate forms in the code, each with a submit button targeted to the frame I want to go to for that action. Put them on the page inside a table with a cell for each form and submit. Looked the way I wanted it to, 2 buttons at the top for the user to choose from, and it worked. Then later I added a 3rd cell and form and submit button, this one calls a servlet on the server that simply updates the database behind it all. No need to make any html to come back to the client.

But when I added the 3rd form and submit to the frame, using exactly the same table structure, just a 3rd cell with the 3rd submit, suddenly there's no form data going back to the server. When I realized it was the 3rd one that made the difference, I went back and forth between 2 versions of the code -- one with 2 form+submit, the other with 3. I can see it with my own eyes, right there -- with 2 it works, form data goes back with the request, with 3, nothing goes back and I get NullPointerExceptions in the servlet code.

I even did a little test servlet that simply checks with an if statement whether there are any parameters returned with the request. That, too, showed that with 2 there are parameters in the request, with 3 there are none.

What???
 
Here's the 2 snippets. I've tried little test servlets using the most basic debugging, sort of like using System.out.println() for regular text-editor debugging, and the top one works, the bottom doesn't. The bottom version returns NO parameters, as found with request.getParameterNames()

String outstring = "<!DOCTYPE HTML PUBLIC \"~//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n" +
"<HTML>\n" +
"<HEAD></HEAD>\n" +
"<BODY>\n" +
"<center><P>HANDY ART BLOCK ASSIGNMENT FORM</P>\n" +
"<TABLE ALIGN=\"center\" BORDER=0 CELLSPACING=0 CELLPADDING=2 WIDTH=\"100%\">" +
" <TD ALIGN=\"center\" VALIGN=\"middle\">" +
" <form method=POST target=\"tableframe\" action=\"http://felecha:8080/ArtBlocks/servlet/UpdateTables\">" +
" <input type=submit value=\" Update Tables \">" +
" </form>" +
" </TD>" +
" <TD ALIGN=\"center\" VALIGN=\"middle\">" +
" <form method=POST target=\"worksheetframe\" action=\"http://felecha:8080/ArtBlocks/servlet/UpdateWorksheet\">" +
" <input type=submit value=\"Update Worksheet\">" +
" </form>" +
" </TD>" +
"</TABLE>" +
"<table cellspacing=0 cellpadding=2 rules=\"all\" bordercolor=\"#000000\" border=\"1\">";


String outstring = "<!DOCTYPE HTML PUBLIC \"~//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n" +
"<HTML>\n" +
"<HEAD></HEAD>\n" +
"<BODY>\n" +
"<center><P>HANDY ART BLOCK ASSIGNMENT FORM</P>\n" +
"<TABLE ALIGN=\"center\" BORDER=0 CELLSPACING=0 CELLPADDING=2 WIDTH=\"100%\">" +
" <TD ALIGN=\"center\" VALIGN=\"middle\">" +
" <form method=POST target=\"tableframe\" action=\"http://felecha:8080/ArtBlocks/servlet/UpdateTables\">" +
" <input type=submit value=\" Update Tables \">" +
" </form>" +
" </TD>" +
" <TD ALIGN=\"center\" VALIGN=\"middle\">" +
" <form method=POST target=\"worksheetframe\" action=\"http://felecha:8080/ArtBlocks/servlet/UpdateWorksheet\">" +
" <input type=submit value=\"Update Worksheet\">" +
" </form>" +
" </TD>" +
" <TD ALIGN=\"center\" VALIGN=\"middle\">" +
" <form method=POST target=\"worksheetframe\" action=\"http://felecha:8080/ArtBlocks/servlet/UpdateDatabase\">" +
" <input type=submit value=\"Update Database\">" +
" </form>" +
" </TD>" +
"</TABLE>" +
"<table cellspacing=0 cellpadding=2 rules=\"all\" bordercolor=\"#000000\" border=\"1\">";


Please remember, I'm learning this as I go, and trying things as I find them in books and web tutorials. I know some general java, but J2EE is new, as is all but the most basic of html. There may be much better ways to do these things, I've just poked around, tried this and that, found things that worked, got into trouble, tried other things, on and on.

Thanks

F
 
I used the tables for layout purposes. I learned about tables this week, and they seem good, and I tried it with a separate form in each cell, each submit intended to point to a different servlet
 
the snippits did nothing for me, except wonder why your doing the html in the servlet, but oh well it can be done. However, I did notice that you have no elements (input boxes and such) to pass data within. What data (params) are you trying to pull out on the servlet side?
 
Back
Top