Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IllegalStateException on page load

 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple index page the i am using as my application entry point. I need this page to call a servlet then return an array of brands to fill in on my home page. Now i alwyas get this error and sometimes the brands never fill in on the page. I have searched and tried different things o found on the web. In the html file i commented the different ways i have tried but still get the same result. Is there a better way to try to do what i am doing or do i just have a syntax error?

Thanks,
John

exception


index.jsp


Servlets






Edited by: jonnyd9191 on Oct 2, 2008 2:56 AM
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64610
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are trying to forward after you have emitted some output. No can do.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64610
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Schretz:
I need this page to call a servlet then return an array of brands to fill in on my home page.

You're doing it backwards. Servlets should call JSPs, not the other way around.

Please see this article for information on accepted best practice web application constructs.
[ October 01, 2008: Message edited by: Bear Bibeault ]
 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, but this jsp page is my entry point. so when i go to www.mypage.com this is the first page called. I then am calling the servlet so i can load my home.jsp page with the proper information. Is there a way that when i go to www.mypage.com the first thing executed is the servlet?

thanks
john
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64610
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
YOu can set any resource to be the welcome file. Please read up on this concept in the deployment descriptor.
 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, i have tried that before.
In my web xml, i did servlet mapping
Then in the welcome file tags i entered the mapped servlet.
This did not work.

<welcome-file>
//mapped servlet here
</welcome-file>
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two redirects in the JSP and one in the servlet

I think you should rework your design, take a good look at the link provided by Bear above, reduce the coupling or the code above will be a maintenance nightmare in near future.

Hope this helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic