• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data Alignment

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers
I'm displaying data using JSTL and JSP by fetching data from the database(back-end, Servlets and Beans). I'm able to display the data successfully but the problem is the alignment of the data. Here's a piece of code from JSP:


Now the data is getting displayed vertically while the table is horizontal. I mean, the headers of the table are Name and Age and the fetched from the db is getting displayed under the Name header only.. i.e. Under Name header itself Age(along with Name) is also getting displayed. I want Name to be displayed under Name header and Age to be displayed under Age.

I know that it is a simple task in HTML but have no idea how to display the same using JSTL. This may be a silly question but any help in this regards would be much appreciated.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All that matters to the browser is the HTML that is sent to it. Do a View Source at the browser to see what's being sent. Is it correct?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hint: you are only creating one <td> so how could you expect two columns?
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear
The View Source seems to be weird. Here's the View Source:


Is my code incorrect ?
And I'm fetching data using a loop, so how can I use 2 <td> ? If I use it twice then both the fields are displaying twice.


 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, How you set the Name and Age in request scope(to display that on front end ). can you post the code?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyway i tell you the way,


in servlet (backend):

set the bean value into List like below




in jsp display like below:




And ,Swapna i encourage you to use jstl


Hope this helps

 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swapna Gouri Kalanidhi wrote:Hi Bear
The View Source seems to be weird. Here's the View Source:


Are you serious? That's just the source of an ordinary HTTP 405 error.
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ SeethaRaman
My code is almost similar to the one you have posted. The only difference is the data being fetched from the database. Here's the code:

This is a code snippet from the bean class. And yes, I have setters and getters too...


@ Bauke
Yes, I'm dead serious, that's what is getting displayed as the page source on the browser. But why is it displaying that way? Is it a problem with my code or with my browser? I'm really confused. :roll:
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Bauke
If that's the source for 404 error, then how am I able to view the desired output? This is even more confusing.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swapna Gouri Kalanidhi wrote:@Bauke
If that's the source for 404 error, then how am I able to view the desired output? This is even more confusing.


Look, it's a 405, not a 404. Look like that your webbrowser fires a brand new GET request on view source of a POST. Try another webbrowser.

That headbanging isn't needed dude. That smiley annoys me.
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first problem is in you first code snippet. You have two columns in the upper row and just one in the bottom row. After the next HTML result you've given us, we can conclude that you have another problem that has nothing to do with columns and even with HTML markup.

P.S. Tomcat generates an extremely ugly error page html markup
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Bauke
Yes, that seems to be a problem with my browser. I was using Google Chrome and when I tried with IE, I faced no problems. I'm able to view the same HTML code that I have written.
And sorry, for that smiley that annoyed you.

@ Vadim
Yes, after viewing the page source, I understood where the problem is. Will modify the code and get back if I have any doubts.

Thanks all for helping me...!
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yes, after viewing the page source, I understood where the problem is. Will modify the code and get back if I have any doubts.

Thanks all for helping me...!

You're welcome.
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This time I'm facing a different error if I try to access the attributes individually. Here's what I'm doing exactly.

Bean class:

The other part of the code was already posted by me, refer the method getCSVDData() in the thread above.

Servlet class:

Now I have modified the JSP a little bit:

Now when I use value.dispatchDate, am getting this HTTP 500 error:

It's clearly saying that it's not able to find the attributes. How should I handle this error?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi swapna,


i mentioned that already about naming convention of bean method




if you make this, code should work.
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@SeethaRaman
I have tried all possible combinations to get the output but still getting the same error.

I'm not able to understand why that error is popping up. How should I move forward from here? :roll:

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ohhhhh.... sorry , i did not see your bean class properly ops: . if this is your java bean methods



then you need to do this



and also let me know, if problem is not solve
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello SeethaRaman
I'm getting the same error still.

What should I do now? I'm not able to make out where the error is lying. I'm afraid if I have coded improperly or have made any silly mistake. :roll:

I really appreciate your patience and help that you are lending me to solve this problem. Thanks a bunch !
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swapna Gouri Kalanidhi wrote:
I'm afraid if I have coded improperly



yes.

here(in your getCSVMethod) you are not using the javabean.



you need to do some thing like this



 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the servlet code:

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, see my previous edited post . you are not setting the values into your javabean. got it?
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I got it. But now am facing a different problem. The intensity is less, though. The setXXX() methods seem to accept only boolean, but what I'm trying to add are Strings. And because of this am getting errors that it cannot take String arguments. If this is the case then I need to change the return type of setters and getters too.

Is "Bean" a predefined class in Java, that I need to import for my purpose? I mean do I need to call the constructor of this predefined Bean class, if one exist, to solve this problem? I have seen something called as "Beans" class but not a "Bean" class. Now what should I do to get rid of this new error? Should I change the return types of my setters and getters to boolean? I don't think this will work, though.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi swapna,

Here i mean ,Bean means TransferObject. your java class here is fine. i dont see any boolean return type . and also you go through my 2nd post of this tread .

 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Seetharaman

Thanks a bunch ! I'm able to display the data successfully.

I have done some simple mistakes due to which a few errors popped up. Now the data is getting displayed very well.

Thanks a lot ! You have helped me a lot, took a lot of pain in explaining me minute details with lot of patience. Thanks a ton !!!
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swapna Gouri Kalanidhi wrote: Thanks a ton !!!



You are Welcome
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic