• Post Reply Bookmark Topic Watch Topic
  • New Topic

Many JSPs submitting to the same servlet

 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have couple of JSPs wherein the action of these pages is a common servlet.

Now I am sending the raw HTML from these pages to the servlet. And here I would want to do some processing based on the related page.

For instance, I would be using XPath to get element values from the pages on some condition.

I want the behaviour like,



Now I am having a hard time how to do it in an idiomatic way. Is there any design pattern that makes sense?

Also how would I be identifying the pages? I suppose giving a form some name.

 
Ivan Jozsef Balazs
Rancher
Posts: 992
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A browser will ususally insert a "Referer" header field, but I would not rely upon this.

You could rethink your design. Maybe some explicit hidden fields would be useful.
 
Sumit Tanwar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does this means, you need to identify which form(jsp) called the servlet ?
and then process accordingly ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I am sending the raw HTML from these pages to the servlet. And here I would want to do some processing based on the related page.


No, you are not sending "raw HTML" the request is formatted according to the HTML rules for forms and interpreted by servlet rules. Using the right terminology helps straight thinking.

I typically use a hidden form element to identify the origin of a request.

Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the servlet is just going to be a series of if/elses then I'd say that's a really poor design. Why do you need to use a single servlet?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!