473,412 Members | 2,277 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Outputting xHTML using JSP backend

5
I want to fetch a set of data from the database and display in the form of a table in the mobile console with frontend as xhtml and backend as servlet.

I tried using the list but got some null pointer exception. I guess its because i cannot use the jsp tags in my xhtml file.

I also wanted an idea as how to go about with xhtml parsing?
Mar 22 '10 #1

✓ answered by jkmyoung

Sounds like the file isn't getting processed as a .jsp file. Have you saved it with a .jsp extension? Further, is jsp supported on the browser you're using?

5 3553
jkmyoung
2,057 Expert 2GB
Could we see how you tried to get the list?
So your output should just be like a typical xhtml table? eg:
<table>
<tr><th>....</th></tr>
....
etc.
Mar 22 '10 #2
reeba
5
This is my servlet side code:
Expand|Select|Wrap|Line Numbers
  1. String sql = "select c_user_id,c_password from t_gb_user_master";
  2.       Statement s = connection.createStatement();
  3.       s.executeQuery (sql);
  4.       rs = s.getResultSet();
  5.       while (rs.next ()){
  6.         //Add records into data list
  7.         dataList.add(rs.getString("c_user_id"));
  8.         dataList.add(rs.getString("c_password"));
  9.       }
  10.       rs.close ();
  11.       s.close ();
  12.       }catch(Exception e){
  13.       System.out.println("Exception is ;"+e);
  14.       }
  15.     System.out.println("dataList SIze : "+dataList.size());
  16.       request.setAttribute("data",dataList);
  17.       //Disptching request
  18.       RequestDispatcher dispatcher = request.getRequestDispatcher(page);
  19.       if (dispatcher != null){
  20.         dispatcher.forward(request, response);

and this is xhtml file:

Expand|Select|Wrap|Line Numbers
  1. <form action="Test1Servlet" method="Post">
  2. <table border="1" width="303">
  3. <tr>
  4. <td>username</td>
  5. <td>password</td>
  6. </tr>
  7. <%Iterator itr;%>
  8. <% List data= (List)request.getAttribute("data");
  9. System.out.println("Data Size : "+data.size());
  10. for (itr=data.iterator(); itr.hasNext(); )
  11. {
  12. %>
  13. <tr>
  14. <td><%=itr.next()%></td>
  15. <td ><%=itr.next()%></td>
  16. </tr>
  17. <%}%>
  18. </table>
  19.     </form>
  20.  

the problem is, the jsp tags are getting displayed as it is in the mobile browser... for example (<%=itr.next()%> is displayed as it is in the output table, in the mobile brower)....
Everything is getting displayed properly in the normal browser...
Mar 23 '10 #3
jkmyoung
2,057 Expert 2GB
Sounds like the file isn't getting processed as a .jsp file. Have you saved it with a .jsp extension? Further, is jsp supported on the browser you're using?
Mar 23 '10 #4
reeba
5
Yes ... I have saved my file as a .jsp file and my browser also supports it.
I am working on a mobile application.
I jus wanted to fetch the data from the database and put it into an xml file dynamically, and display it in the mobile browser....
and later if i need to fetch the data I should be able to fetch it from the xml file rather than the database....
can u help me as to how i can go about with it
Mar 24 '10 #5
jkmyoung
2,057 Expert 2GB
Can you get even simple statements like this to work?
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. System.out.println("JSP is working");
  3. java.util.Date date = new java.util.Date();
  4. %>
  5. The time is now <%= date %>
Forgive me for asking: but when you say " I have saved my file as a .jsp file" do you mean:
1. It was always saved as a .jsp file but wasn't working?
2. You just now saved your file to a .jsp file and the .jsp started working but failing?
Mar 24 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Francis Hwang | last post by:
Hi, Maybe this is a newbie question, but: Is there a way to output an element's contents -- including contained nodes and free-form text -- without the containing tags? I can imagine that...
1
by: Saqib Ali | last post by:
Hello Everybody, I am writing a simple web interface to onsgmls for validating HTML 4.01, XHTML 1.0, and DocBook 4.1.2. The web interface in PHP, and uses ongsmls...
5
by: Ben Jessel | last post by:
I am in the process of converting my site to using XHTML and CSS. A lot of my sites include tables of data, which are highlighted using javascript rollovers. I have converted my a lot of my...
8
by: David Dorward | last post by:
I'm looking for an XSLT that I can use to transform XHTML 1.0 Strict into HTML 4.01. Does anyone know of a nice prewritten one? -- David Dorward ...
16
by: Mcginkel | last post by:
I am trying to find a way to load XHTML content in an Iframe. I use to do this in html by using the following code : var iframeObject = document.createElement("iframe");...
2
by: Joris Janssens | last post by:
I'm trying to write a program for validating XHTML 1.1-documents against the XHTML 1.1 DTD (which is actually the same as validating an XML-file) but I always get a "(404) Not found" error. This...
12
by: Alex D. | last post by:
How can I stop asp.net from rendering XHTML istead of HTML? My javascripts are rendering wrong because of that. It is rendering &amp; to clients instead of &. Any help? Thanks, Alejandro.
3
by: BakedBean | last post by:
Hi, This is probably really simple, but I've only just been asked to look at this and I've spent a full day trying to get it to work, so any help will be very gratefully received! At present...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
1
by: wbrands2 | last post by:
I am new to this forum and to javascript I have something due for class tomorrow but I can't figure out what is wrong with this code that it won't output a table to the screen. I don't understand how...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.