java - Servlet returns text and not HTML -


$(document).ready(function() {                              $.get('navigation', function(responsetext) {             $('#navi').text(responsetext);               }); }); 

i calling servlet named 'navigation' in order result in div id 'navi'. servlet works fine. code in div shown text , not rendered html-code.

edit:

public void doget(httpservletrequest request,                   httpservletresponse response)           throws servletexception, ioexception {      response.setcontenttype("text/html");     response.setcharacterencoding("utf-8");      printwriter out = response.getwriter();      dao = new webshopdao();      kategorien = dao.gibkategorien();      out.println("<ul>");     (katalog k1 : kategorien) {           integer oberkat = k1.getoberkategorienr();         if (oberkat == 0) {         out.println("<li class='has-sub'><a>" + k1.getkname() + "</a>\n");             (katalog k2 : kategorien) {                 if (objects.equals(k2.getoberkategorienr(), k1.getkategorienr())) {                     out.println("<ul>\n<li><a><form method='get'><button type='submit' name='category' value='"                                + k2.getkategorienr() + "'>" + k2.getkname() + "</button></form></a></li>\n</ul>\n");                 }             }         out.println("</li>\n");                         }               }      out.println("</ul>"); } 

edit2 :

    <li class='has-sub'><a>lebensmittel</a> <ul>  <li><a><form method='get'><button type='submit' name='category' value='5'>reis</button></form></a></li>  <li><a><form method='get'><button type='submit' name='category' value='6'>gewürze</button></form></a></li>  <li><a><form method='get'><button type='submit' name='category' value='7'>tee</button></form></a></li>  <li><a><form method='get'><button type='submit' name='category' value='8'>snacks</button></form></a></li>  </ul></li>   <li class='has-sub'><a>küche & haushalt</a> <ul>  <li><a><form method='get'><button type='submit' name='category' value='9'>reiskocher</button></form></a></li>  <li><a><form method='get'><button type='submit' name='category' value='10'>besteck</button></form></a></li>  </ul></li>   <li class='has-sub'><a>bücher</a> <ul>  <li><a><form method='get'><button type='submit' name='category' value='13'>geschichte</button></form></a></li>  <li><a><form method='get'><button type='submit' name='category' value='14'>sprachen</button></form></a></li>  <li><a><form method='get'><button type='submit' name='category' value='15'>reiseführer</button></form></a></li>  </ul></li>   <li class='has-sub'><a>sonstiges</a> <ul>  <li><a><form method='get'><button type='submit' name='category' value='16'>t-shirts</button></form></a></li>  <li><a><form method='get'><button type='submit' name='category' value='17'>poster</button></form></a></li>  </ul></li> 

edit 3:

it seems servlet not see css, cannot open category. how can tell servlet add css if not have head tag?

use .html(),

.text() treats input string plain text; html() treats html.

$('#navi').html(responsetext); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -