Results 1 to 5 of 5
- 07-11-2018, 06:44 AM #1
Senior Member
- Join Date
- Dec 2016
- Posts
- 103
- Rep Power
- 0
JSP "else" syntax error with html
i am trying to checking the connection status of my java code with mysql DB the it showing this error (Syntax error on token "else", delete this token)
Please Help !
Thanks
Java Code:<h1 class='text-center'>Welcome </h1> <%! ResultSet rst; %> <% try { Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306:demo?useSSL=false","root","password"); PreparedStatement pst=con.prepareStatement("select * from data"); ResultSet rst=pst.executeQuery(); %> <% if (con != null){ out.println("<h1>Connected</h1>") ; }%> <% else { out.println("<h1>Not Connected</h1>") ; } %>
Last edited by vknehra10; 07-11-2018 at 07:08 AM.
- 07-11-2018, 04:12 PM #2
Senior Member
- Join Date
- Sep 2014
- Location
- MA, USA
- Posts
- 399
- Rep Power
- 7
Re: JSP "else" syntax error with html
if (){} else {} have to be in the same html/JSP tag.
No catch statement for your connection?
- 07-16-2018, 03:54 PM #3
Senior Member
- Join Date
- Dec 2016
- Posts
- 103
- Rep Power
- 0
Re: JSP "else" syntax error with html
catch statement is in last
if i write if and else in same jsp tag , then where i put the html code if "if statement" will be correct ?
- 07-16-2018, 04:03 PM #4
Senior Member
- Join Date
- Sep 2014
- Location
- MA, USA
- Posts
- 399
- Rep Power
- 7
Re: JSP "else" syntax error with html
write a complete Java code that covers each outcome and then surround it with the tags.
- 07-16-2018, 05:24 PM #5
Senior Member
- Join Date
- Dec 2016
- Posts
- 103
- Rep Power
- 0
Similar Threads
-
newbie need help with query result in List
By aliaj00 in forum HibernateReplies: 3Last Post: 12-11-2014, 11:47 AM -
where to put the result of query?
By wiz6 in forum Java ServletReplies: 2Last Post: 07-17-2013, 12:08 PM -
Using jTable to display query result
By zenith666 in forum New To JavaReplies: 2Last Post: 01-13-2012, 03:29 AM -
column result query
By vikashkumar in forum JDBCReplies: 0Last Post: 04-03-2009, 03:23 PM -
Help!! how to turn query result to string
By stefanybaez in forum Advanced JavaReplies: 2Last Post: 12-11-2008, 12:42 PM
Bookmarks